Skip to content

Commit

Permalink
status: Allow passing -verbose to meta status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
endocrimes committed Apr 4, 2019
1 parent 010b957 commit 1ad1bb1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion command/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -23,7 +26,13 @@ Usage: nomad status [options] <identifier>
General Options:
` + generalOptionsUsage()
` + generalOptionsUsage() + `
Status Options:
-verbose
Display full information.
`

return strings.TrimSpace(helpText)
}
Expand Down Expand Up @@ -65,6 +74,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))
Expand Down

0 comments on commit 1ad1bb1

Please sign in to comment.