So, consider following scenario:

  virsh # migrate --help

In this case migrate help is printed out. So far so good.
However, you start writing this long migrate command (I bet you
know the arguments  there can get quite long), but then, at some
point you need to print out the help. Something like this:

  virsh # migrate --copy-storage-all --migrate-disks --help

In this specific case you just want to see the format that
--migrate-disks accepts. So you append --help and expect help to
be printed out. Well, it will not, because "--help" is taken as
data to --migrate-disks. Therefore we will get this error
instead:

  virsh # migrate --copy-storage-all --migrate-disks --help
  error: command 'migrate' requires <domain> option
  error: command 'migrate' requires <desturi> option

Teach our parsing code, that --help may occur even in argument
data, and therefore anywhere on the command line.

Signed-off-by: Michal Privoznik <[email protected]>
---
 tools/vsh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index e57c324..d67f5de 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1415,7 +1415,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
             /* if we encountered --help, replace parsed command with
              * 'help <cmdname>' */
             for (tmpopt = first; tmpopt; tmpopt = tmpopt->next) {
-                if (STRNEQ(tmpopt->def->name, "help"))
+                if (STRNEQ(tmpopt->def->name, "help") &&
+                    STRNEQ_NULLABLE(tmpopt->data, "--help"))
                     continue;
 
                 const vshCmdDef *help = vshCmddefSearch("help");
-- 
2.4.10

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to