vshRebootShutdownModeCompleter returns available shutdown mode names. This can be used for --mode auto completion for commands such as reboot or shutdown. for example: virsh # reboot --mode <TAB> acpi agent initctl signal virsh # reboot --mode i<TAB> virsh # reboot --mode initctl --- v3 * removed useless if * used virStringFreeList() instead of iteration * moved all .completer = vshRebootShutdownModeCompleter initializations into this patch v4 * rewritten using virStringSplit() tools/virsh-domain.c | 6 ++++-- tools/virsh.c | 6 ++++++ tools/virsh.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 1406d2e..69014dd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4801,7 +4801,8 @@ static const vshCmdOptDef opts_shutdown[] = { }, {.name = "mode", .type = VSH_OT_STRING, - .help = N_("shutdown mode: acpi|agent|initctl|signal") + .help = N_("shutdown mode: acpi|agent|initctl|signal"), + .completer = vshRebootShutdownModeCompleter }, {.name = NULL} }; @@ -4889,7 +4890,8 @@ static const vshCmdOptDef opts_reboot[] = { }, {.name = "mode", .type = VSH_OT_STRING, - .help = N_("shutdown mode: acpi|agent|initctl|signal") + .help = N_("shutdown mode: acpi|agent|initctl|signal"), + .completer = vshRebootShutdownModeCompleter }, {.name = NULL} }; diff --git a/tools/virsh.c b/tools/virsh.c index cb89187..7e7a0d5 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2636,6 +2636,12 @@ vshSuspendTargetCompleter(unsigned int unused_flags ATTRIBUTE_UNUSED) return virStringSplit("mem disk hybrid", " ", 0); } +char ** +vshRebootShutdownModeCompleter(unsigned int unused_flags ATTRIBUTE_UNUSED) +{ + return virStringSplit("acpi agent initctl signal", " ", 0); +} + #ifdef USE_READLINE /* ----------------- diff --git a/tools/virsh.h b/tools/virsh.h index c8e3d38..4763db3 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -260,6 +260,7 @@ struct _vshCmdGrp { char **vshDomainCompleter(unsigned int flags); char **vshSuspendTargetCompleter(unsigned int unused_flags); +char **vshRebootShutdownModeCompleter(unsigned int unused_flags); void vshError(vshControl *ctl, const char *format, ...) ATTRIBUTE_FMT_PRINTF(2, 3); -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list