From 38e73b51e9e468f20dc35082acebd109bf07ec05 Mon Sep 17 00:00:00 2001 From: Danielle Lancashire Date: Thu, 4 Apr 2019 19:35:20 +0200 Subject: [PATCH] status: Allow passing -verbose to meta status A common issue when using nomad is needing to add in the object verb to a command to include the `-verbose` flag. This commit allows users to pass `-verbose` via the `nomad status` alias by adding a placeholder boolean in the metacommand which allows subcommands to parse the flag. --- command/status.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/command/status.go b/command/status.go index 89faf6c3ef7..4cf028b3965 100644 --- a/command/status.go +++ b/command/status.go @@ -11,6 +11,9 @@ import ( type StatusCommand struct { Meta + + // Placeholder bool to allow passing of verbose flags to subcommands. + verbose bool } func (s *StatusCommand) Help() string { @@ -23,7 +26,13 @@ Usage: nomad status [options] General Options: - ` + generalOptionsUsage() + ` + generalOptionsUsage() + ` + +Status Options: + + -verbose + Display full information. +` return strings.TrimSpace(helpText) } @@ -33,7 +42,10 @@ func (c *StatusCommand) Synopsis() string { } func (c *StatusCommand) AutocompleteFlags() complete.Flags { - return c.Meta.AutocompleteFlags(FlagSetClient) + return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient), + complete.Flags{ + "-verbose": complete.PredictNothing, + }) } func (c *StatusCommand) AutocompleteArgs() complete.Predictor { @@ -65,6 +77,7 @@ func (c *StatusCommand) AutocompleteArgs() complete.Predictor { func (c *StatusCommand) Run(args []string) int { flags := c.Meta.FlagSet("status", FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } + flags.BoolVar(&c.verbose, "verbose", false, "") if err := flags.Parse(args); err != nil { c.Ui.Error(fmt.Sprintf("Error parsing arguments: %q", err))