Re: [libvirt] Remove OPTION section in output of 'virsh help command' if no option exists.
On 05/21/2013 09:15 PM, Zhang Xiaohe wrote: Don't print 'OPTION' if there's no options. Just behaves as DESCRIPTION does. This mostly affects 'interface' command group. Signed-off-by: Zhang Xiaohe zhan...@cn.fujitsu.com Reported-by: Li Yang liyang.f...@cn.fujitsu.com --- tools/virsh.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) For some reason, the patch didn't apply for me with 'git am', so I had to do it by hand; in the process, I simplified slightly. diff --git a/tools/virsh.c b/tools/virsh.c index ecb7bd4..7c60800 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1270,7 +1270,9 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) if (def-opts) { const vshCmdOptDef *opt; -fputs(_(\n OPTIONS\n), stdout); +/* Print the option only if there are options */ +if (def-opts-name) +fputs(_(\n OPTIONS\n), stdout); Hmm, I wonder why we even bother to create 1-element arrays with a NULL terminator instead of passing NULL when registering option-less functions, on commands like 'iface-commit'. But your idea is fine. ACK and here's what I pushed, after tweaking the subject line to be shorter: diff --git a/tools/virsh.c b/tools/virsh.c index ecb7bd4..6f0c1ef 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1268,7 +1268,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) fprintf(stdout, %s\n, _(desc)); } -if (def-opts) { +if (def-opts def-opts-name) { const vshCmdOptDef *opt; fputs(_(\n OPTIONS\n), stdout); for (opt = def-opts; opt-name; opt++) { -- 1.8.1.4 -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Remove OPTION section in output of 'virsh help command' if no option exists.
于 2013年05月23日 06:19, Eric Blake 写道: On 05/21/2013 09:15 PM, Zhang Xiaohe wrote: Don't print 'OPTION' if there's no options. Just behaves as DESCRIPTION does. This mostly affects 'interface' command group. Signed-off-by: Zhang Xiaohezhan...@cn.fujitsu.com Reported-by: Li Yangliyang.f...@cn.fujitsu.com --- tools/virsh.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) For some reason, the patch didn't apply for me with 'git am', so I had to do it by hand; in the process, I simplified slightly. diff --git a/tools/virsh.c b/tools/virsh.c index ecb7bd4..7c60800 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1270,7 +1270,9 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) if (def-opts) { const vshCmdOptDef *opt; -fputs(_(\n OPTIONS\n), stdout); +/* Print the option only if there are options */ +if (def-opts-name) +fputs(_(\n OPTIONS\n), stdout); Hmm, I wonder why we even bother to create 1-element arrays with a NULL terminator instead of passing NULL when registering option-less functions, on commands like 'iface-commit'. But your idea is fine. ACK and here's what I pushed, after tweaking the subject line to be shorter: diff --git a/tools/virsh.c b/tools/virsh.c index ecb7bd4..6f0c1ef 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1268,7 +1268,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) fprintf(stdout, %s\n, _(desc)); } -if (def-opts) { +if (def-opts def-opts-name) { const vshCmdOptDef *opt; fputs(_(\n OPTIONS\n), stdout); for (opt = def-opts; opt-name; opt++) { Thanks, this looks more pretty~ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Remove OPTION section in output of 'virsh help command' if no option exists.
Don't print 'OPTION' if there's no options. Just behaves as DESCRIPTION does. This mostly affects 'interface' command group. Signed-off-by: Zhang Xiaohe zhan...@cn.fujitsu.com Reported-by: Li Yang liyang.f...@cn.fujitsu.com --- tools/virsh.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index ecb7bd4..7c60800 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1270,7 +1270,9 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) if (def-opts) { const vshCmdOptDef *opt; -fputs(_(\n OPTIONS\n), stdout); +/* Print the option only if there are options */ +if (def-opts-name) +fputs(_(\n OPTIONS\n), stdout); for (opt = def-opts; opt-name; opt++) { switch (opt-type) { case VSH_OT_BOOL: -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list