cli: fix missing `-quiet` flag for `var init` (#17526)

The `var init` command was intended to have support for a `-quiet` flag but it
was not documented and never parsed.
This commit is contained in:
Tim Gross 2023-06-14 14:52:46 -04:00 committed by GitHub
parent 736ad3ed32
commit 5f509b8ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

3
.changelog/17526.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
cli: Add `-quiet` flag to `nomad var init` command
```

View File

@ -44,6 +44,8 @@ Init Options:
-out (hcl | json)
Format of generated variable specification. Defaults to "hcl".
-quiet
Do not print success message.
`
return strings.TrimSpace(helpText)
}
@ -55,6 +57,7 @@ func (c *VarInitCommand) Synopsis() string {
func (c *VarInitCommand) AutocompleteFlags() complete.Flags {
return complete.Flags{
"-out": complete.PredictSet("hcl", "json"),
"-quiet": complete.PredictNothing,
}
}
@ -71,6 +74,7 @@ func (c *VarInitCommand) Run(args []string) int {
flags := c.Meta.FlagSet(c.Name(), FlagSetClient)
flags.Usage = func() { c.Ui.Output(c.Help()) }
flags.StringVar(&outFmt, "out", "hcl", "")
flags.BoolVar(&quiet, "quiet", false, "")
if err := flags.Parse(args); err != nil {
return 1

View File

@ -24,6 +24,8 @@ When no filename is supplied, a default filename of "spec.nv.hcl" or
- `-out` `(enum: hcl | json)`: Format of generated variable
specification. Defaults to `hcl`.
- `-quiet`: Do not print success message.
## Examples
Create an example variable specification: