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

Re: [libvirt] [PATCH 6/8] virsh: Add completer functions to domManaggementCmds



On 08.08.2013 16:38, Tomas Meszaros wrote:
> Add .completer and .completer_flags to domManagementCmds.
> 
> vshDomainCompleter (with appropriate flags) is enabled for
> commands requiring only single <domain> argument.
> ---
>  tools/virsh-domain.c | 230 ++++++++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 180 insertions(+), 50 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 5e1196f..b89b219 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -2752,7 +2752,8 @@ static const vshCmdOptDef opts_dom_pm_suspend[] = {
>       .flags = VSH_OFLAG_REQ,
>       .help = N_("mem(Suspend-to-RAM), "
>                  "disk(Suspend-to-Disk), "
> -                "hybrid(Hybrid-Suspend)")
> +                "hybrid(Hybrid-Suspend)"),
> +     .completer = vshSuspendTargetCompleter

It makes more sense to add this chunk to the patch introducing
vshSuspendTargetCompleter (3/8 that is). In fact, I think you need to
reorder the patches. 1/8 is correct (from ordering POV). It should be
followed by 5/8 and then the rest of the patches which add completers.

>      },
>      {.name = NULL}
>  };
> @@ -4707,7 +4708,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}
>  };
> @@ -4793,7 +4795,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}
>  };
> @@ -10333,7 +10336,10 @@ const vshCmdDef domManagementCmds[] = {
>       .handler = cmdAutostart,
>       .opts = opts_autostart,
>       .info = info_autostart,
> -     .flags = 0
> +     .flags = 0,
> +     .completer = vshDomainCompleter,
> +     .completer_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE |
> +                        VIR_CONNECT_LIST_DOMAINS_INACTIVE

Nice! It's super-easy for other commands to profit from well written
(read generic enough) completer. Just pass the correct flags.

Michal


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