Re: [PATCH 3/3] virsh: make 'help' command ignore spurious options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/13/2012 02:53 PM, Doug Goldstein wrote:
> On Mon, Aug 13, 2012 at 9:28 AM, Cole Robinson <crobinso@xxxxxxxxxx> wrote:
>> Similar to the previous patch, prepending 'help' to a partial
>> command string doesn't cut us any slack.
>>
>> $ virsh help pool-define-as --name foo --type dir
>> error: command 'help' doesn't support option --name
>>
>> This patch adds a few hacks to make 'help' ignore everything after the
>> first data bit, so the above command shows help output for pool-define-as.
>> ---
>>  tools/virsh.c | 13 ++++++++++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/virsh.c b/tools/virsh.c
>> index 324f789..ab8d6dc 100644
>> --- a/tools/virsh.c
>> +++ b/tools/virsh.c
>> @@ -1219,8 +1219,10 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
>>          }
>>      }
>>
>> -    vshError(ctl, _("command '%s' doesn't support option --%s"),
>> -             cmd->name, name);
>> +    if (STRNEQ(cmd->name, "help")) {
>> +        vshError(ctl, _("command '%s' doesn't support option --%s"),
>> +                 cmd->name, name);
>> +    }
>>      return NULL;
>>  }
>>
>> @@ -1987,9 +1989,12 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
>>                      *optstr = '\0'; /* convert the '=' to '\0' */
>>                      optstr = vshStrdup(ctl, optstr + 1);
>>                  }
>> +                /* Special case 'help' to ignore all spurious options */
>>                  if (!(opt = vshCmddefGetOption(ctl, cmd, tkdata + 2,
>>                                                 &opts_seen, &opt_index))) {
>>                      VIR_FREE(optstr);
>> +                    if (STREQ(cmd->name, "help"))
>> +                        continue;
>>                      goto syntaxError;
>>                  }
>>                  VIR_FREE(tkdata);
>> @@ -2027,8 +2032,10 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
>>                  continue;
>>              } else {
>>  get_data:
>> +                /* Special case 'help' to ignore spurious data */
>>                  if (!(opt = vshCmddefGetData(cmd, &opts_need_arg,
>> -                                             &opts_seen))) {
>> +                                             &opts_seen)) &&
>> +                     STRNEQ(cmd->name, "help")) {
>>                      vshError(ctl, _("unexpected data '%s'"), tkdata);
>>                      goto syntaxError;
>>                  }
>> --
>> 1.7.11.2
>>
> 
> Worked for me when I tested it with the previous patches so ACK.
> 
> 

Thanks guys, pushed now.

- Cole

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]