From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V27pY-0002qa-6S for qemu-devel@nongnu.org; Wed, 24 Jul 2013 18:46:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V27pW-0000Vq-5a for qemu-devel@nongnu.org; Wed, 24 Jul 2013 18:46:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V27pV-0000Vb-Tp for qemu-devel@nongnu.org; Wed, 24 Jul 2013 18:46:46 -0400 Message-ID: <51F05951.2080800@redhat.com> Date: Wed, 24 Jul 2013 16:46:41 -0600 From: Eric Blake MIME-Version: 1.0 References: <1374284656-12025-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1374284656-12025-10-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1374284656-12025-10-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ClDXAfwEQR6Q6uMOX756PaSrM6jaCmJMg" Subject: Re: [Qemu-devel] [PATCH V7 09/13] monitor: support sub command in help List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: armbru@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ClDXAfwEQR6Q6uMOX756PaSrM6jaCmJMg Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/19/2013 07:44 PM, Wenchao Xia wrote: > The old code in help_cmd() use global 'info_cmds' and treat it as a s/use/uses/; s/treat/treats/ > special case. Actually 'info_cmds' is an sub command group of 'mon_cmds= ', s/an sub/a sub/ > in order to avoid direct use of it, help_cmd() need to change its work s/need/needs/ > mechanism to support sub command and not treat it as a special case > any more. >=20 > To support sub command, help_cmd() will first parse the input and then = call > help_cmd_dump(), which works as an reentrant function. When it mets sub= s/an/a/; s/mets/meets a/ > command, it simply re-enter the function again. Since help dumping need= to s/re-enter/enters/; s/need/needs/ > know whole input to printf full help message include prefix, for exampl= e, > "help info block" need to printf prefix "info", so help_cmd_dump() take= s all > args from input and extra parameter arg_index to identify the progress.= > Another function help_cmd_dump_one() is introduced to printf the prefix= > and command's help message. >=20 > Now help support sub command, so later if another sub command group is s/support/supports/ > added in any depth, help will automatically work for it. Still "help in= fo > block" will show error since command parser reject additional parameter= , > which can be improved later. "log" is still treated as a special case. >=20 > Signed-off-by: Wenchao Xia > --- > monitor.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++--= ------- > 1 files changed, 53 insertions(+), 10 deletions(-) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ClDXAfwEQR6Q6uMOX756PaSrM6jaCmJMg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR8FlRAAoJEKeha0olJ0Nq/1QIAIhaeAqi4bd6kzcoJHXGoyGW pG9h2+PsWv/5uL3NlJQf4y5MRsxClPeEbdNRrfIrOywy2S4X9EKDCwa6mjkK1Jot E0gegWe/0GY+ovj+ovUCNmhKbJelGKwu2v3qZvXhF/A1pZO0yj8fAVNKhNqiYJyE yGGchDdxQJzvDCG8MHglnZVuiaD82Kx3Hz12cr6qQOPpqEfcI/an7os+kEizzU4V bg4HydhrxxbIEIUJOqTpy+CUPTVn4K99k7WU5jdw1ufiLsskIHuEEIGykr4ZqSY5 IqPCsioisC3tXB9i6RX2M2xJ8D9xUn5smyAgv1Wcp249C5rJpw+/sFbKTkBcsnY= =5kxi -----END PGP SIGNATURE----- --ClDXAfwEQR6Q6uMOX756PaSrM6jaCmJMg--