mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
vshCmdGrpHelp: Refactor formatting of help for VSH_OT_ARGV
Use the new properties rather than infer the states. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
55a07252ec
commit
e177b0fca6
33
tools/vsh.c
33
tools/vsh.c
@ -634,8 +634,6 @@ vshCmdGrpHelp(vshControl *ctl, const vshCmdGrp *grp)
|
||||
static bool
|
||||
vshCmddefHelp(const vshCmdDef *def)
|
||||
{
|
||||
bool shortopt = false; /* true if 'arg' works instead of '--opt arg' */
|
||||
|
||||
fputs(_(" NAME\n"), stdout);
|
||||
fprintf(stdout, " %s - %s\n", def->name, _(def->info->help));
|
||||
|
||||
@ -657,16 +655,10 @@ vshCmddefHelp(const vshCmdDef *def)
|
||||
} else {
|
||||
fprintf(stdout, _(" [--%1$s <number>]"), opt->name);
|
||||
}
|
||||
|
||||
if (!(opt->flags & VSH_OFLAG_REQ_OPT))
|
||||
shortopt = true;
|
||||
break;
|
||||
|
||||
case VSH_OT_STRING:
|
||||
fprintf(stdout, _(" [--%1$s <string>]"), opt->name);
|
||||
|
||||
if (!(opt->flags & VSH_OFLAG_REQ_OPT))
|
||||
shortopt = true;
|
||||
break;
|
||||
|
||||
case VSH_OT_DATA:
|
||||
@ -675,24 +667,21 @@ vshCmddefHelp(const vshCmdDef *def)
|
||||
} else {
|
||||
fprintf(stdout, " [<%s>]", opt->name);
|
||||
}
|
||||
|
||||
if (!(opt->flags & VSH_OFLAG_REQ_OPT))
|
||||
shortopt = true;
|
||||
break;
|
||||
|
||||
case VSH_OT_ARGV:
|
||||
if (shortopt) {
|
||||
if (required_option) {
|
||||
fprintf(stdout, _(" {[--%1$s] <string>}..."), opt->name);
|
||||
} else {
|
||||
fprintf(stdout, _(" [[--%1$s] <string>]..."), opt->name);
|
||||
}
|
||||
} else {
|
||||
if (required_option) {
|
||||
if (opt->positional) {
|
||||
if (opt->required) {
|
||||
fprintf(stdout, " <%s>...", opt->name);
|
||||
} else {
|
||||
fprintf(stdout, " [<%s>]...", opt->name);
|
||||
}
|
||||
} else {
|
||||
if (opt->required) {
|
||||
fprintf(stdout, _(" {[--%1$s] <string>}..."), opt->name);
|
||||
} else {
|
||||
fprintf(stdout, _(" [[--%1$s] <string>]..."), opt->name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -740,10 +729,10 @@ vshCmddefHelp(const vshCmdDef *def)
|
||||
break;
|
||||
|
||||
case VSH_OT_ARGV:
|
||||
if (shortopt) {
|
||||
optstr = g_strdup_printf(_("[--%1$s] <string>"), opt->name);
|
||||
} else {
|
||||
if (opt->positional) {
|
||||
optstr = g_strdup_printf("<%s>", opt->name);
|
||||
} else {
|
||||
optstr = g_strdup_printf(_("[--%1$s] <string>"), opt->name);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user