On Wed, May 25, 2011 at 05:37:43PM +0800, Lai Jiangshan wrote: > A name will improve the usege, example > > # virsh help echo > NAME > echo - echo arguments > > SYNOPSIS > echo [--shell] [--xml] [<string>]... > > DESCRIPTION > Echo back arguments, possibly with quoting. > > OPTIONS > --shell escape for shell use > --xml escape for XML use > <string> arguments to echo > > "[<string>]..." is added to SYNOPSIS. > "<string> arguments to echo" is added to OPTIONS. > > Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxx> > --- > tools/virsh.c | 19 +++++++++++++------ > 1 files changed, 13 insertions(+), 6 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index de49489..c358580 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -126,7 +126,7 @@ typedef enum { > VSH_OT_STRING, /* optional string option */ > VSH_OT_INT, /* optional or mandatory int option */ > VSH_OT_DATA, /* string data (as non-option) */ > - VSH_OT_ARGV /* remaining arguments, opt->name should be "" */ > + VSH_OT_ARGV /* remaining arguments */ > } vshCmdOptType; > > /* > @@ -10046,7 +10046,7 @@ static const vshCmdInfo info_echo[] = { > static const vshCmdOptDef opts_echo[] = { > {"shell", VSH_OT_BOOL, 0, N_("escape for shell use")}, > {"xml", VSH_OT_BOOL, 0, N_("escape for XML use")}, > - {"", VSH_OT_ARGV, 0, N_("arguments to echo")}, > + {"string", VSH_OT_ARGV, 0, N_("arguments to echo")}, > {NULL, 0, 0, NULL} > }; > > @@ -11084,6 +11084,11 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, > vshError(ctl, _("option --%s already seen"), name); > return NULL; > } > + if (opt->type == VSH_OT_ARGV) { > + vshError(ctl, _("variable argument <%s> " > + "should not be used with --<%s>"), name, name); > + return NULL; > + } > *opts_seen |= 1 << i; > return opt; > } > @@ -11132,7 +11137,7 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required, > const vshCmdOptDef *opt = &def->opts[i]; > > vshError(ctl, > - opt->type == VSH_OT_DATA ? > + opt->type == VSH_OT_DATA || opt->type == VSH_OT_ARGV ? > _("command '%s' requires <%s> option") : > _("command '%s' requires --%s option"), > def->name, opt->name); > @@ -11240,7 +11245,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) > break; > case VSH_OT_ARGV: > /* xgettext:c-format */ > - fmt = _("[<string>]..."); > + fmt = (opt->flag & VSH_OFLAG_REQ) ? _("<%s>...") > + : _("[<%s>]..."); > break; > default: > assert(0); > @@ -11280,7 +11286,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) > break; > case VSH_OT_ARGV: > /* Not really an option. */ > - continue; > + snprintf(buf, sizeof(buf), _("<%s>"), opt->name); > + break; > default: > assert(0); > } > @@ -12693,7 +12700,7 @@ vshReadlineOptionsGenerator(const char *text, int state) > > list_index++; > > - if (opt->type == VSH_OT_DATA) > + if (opt->type == VSH_OT_DATA || opt->type == VSH_OT_ARGV) > /* ignore non --option */ > continue; > ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list