]> git.proxmox.com Git - mirror_qemu.git/commit - monitor.c
monitor: support sub command in help
authorWenchao Xia <xiawenc@linux.vnet.ibm.com>
Tue, 27 Aug 2013 12:38:23 +0000 (20:38 +0800)
committerLuiz Capitulino <lcapitulino@redhat.com>
Fri, 30 Aug 2013 11:41:15 +0000 (07:41 -0400)
commit66855495fbcca9411a21e6eba6a3a0385007c96d
treed6048b1682d72c39882880804e89ce2500e57bae
parentdcc70cdf0932172fc5cf27617a3b033ca58d0176
monitor: support sub command in help

The old code in help_cmd() uses global 'info_cmds' and treats it as a
special case. Actually 'info_cmds' is a sub command group of 'mon_cmds',
in order to avoid direct use of it, help_cmd() needs to change its work
mechanism to support sub command and not treat it as a special case
any more.

To support sub command, help_cmd() will first parse the input and then call
help_cmd_dump(), which works as a reentrant function. When it meets a sub
command, it simply enters the function again. Since help dumping needs to
know whole input to printf full help message include prefix, for example,
"help info block" need to printf prefix "info", so help_cmd_dump() takes 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.

Now help supports sub command, so later if another sub command group is
added in any depth, help will automatically work for it. Still "help info
block" will show error since command parser reject additional parameter,
which can be improved later. "log" is still treated as a special case.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
monitor.c