cli: fix -t flag on job status command (#24054)

In #18925 we added a `-json` flag to the `job status` command, but the argument
handling had a bug where it would always set the `-json` flag if either the `-t`
or `-json` flags were set, resulting in a misleading error. Instead, pass the
`-json` flag value into the formatter.

Fixes: https://github.com/hashicorp/nomad/issues/24050
This commit is contained in:
Tim Gross
2024-09-25 09:12:52 -04:00
committed by GitHub
parent cc9227b858
commit 65ec00da1d
2 changed files with 5 additions and 2 deletions

3
.changelog/24054.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
cli: Fixed a bug in job status command where -t would act as though -json was also set
```

View File

@@ -173,7 +173,7 @@ func (c *JobStatusCommand) Run(args []string) int {
return 1
}
out, err := Format(true, c.tmpl, jsonJobs)
out, err := Format(c.json, c.tmpl, jsonJobs)
if err != nil {
c.Ui.Error(err.Error())
return 1
@@ -220,7 +220,7 @@ func (c *JobStatusCommand) Run(args []string) int {
return 1
}
out, err := Format(true, c.tmpl, jsonJobs)
out, err := Format(c.json, c.tmpl, jsonJobs)
if err != nil {
c.Ui.Error(err.Error())
return 1