Skip to content

fix(cli): scaffold export and ctx set stop hiding the global -o/--output flag - #399

Merged
bmscomp merged 1 commit into
mainfrom
fix/cli-local-output-flags-renamed
Oct 18, 2026
Merged

bmscomp merged 1 commit into
mainfrom
fix/cli-local-output-flags-renamed

Conversation

@bmscomp

@bmscomp bmscomp commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Item 1.10 of the CLI performance and stability plan (finding F15, its local-flag rows). Independent of the other Wave 1 PRs. It renames two flags; see Release note.

Why

Two commands define their own --output, which hides the global -o/--output output-format flag. On main (6f4cf61):

  • kates test scaffold export quick-load -o json writes the template to a file named json (cli/cmd/scaffold.go:229, StringVarP(…, "output", "o", …)).
  • kates ctx set foo --url … -o json fails with unknown shorthand flag: 'o' (cli/cmd/config.go:482). Its own --output, the context's default format, has no shorthand.

Changes

  • cli/cmd/scaffold.go: the export filename flag is --file/-f.
  • cli/cmd/config.go:
    • The context's default format is --default-output.
    • The help example uses it.
    • ctx set notes on stderr when it gets --output without --default-output. A script written for the old flag now sets this command's output format and leaves the context at table, so it should hear about it.
  • cli/cmd/data/doc_entries.yaml (kates docs): the ctx set flag and example.
  • The book (10-cli-reference.md, 13-scenario-files.md) and the tutorials (02-all-test-types.md, 06-cicd-integration.md): 8 scaffold export … -o <file> examples become -f <file>.

-o and --output on both commands are now the global flag.

Release note

Renamed flags. kates test scaffold export --output/-o <file> is now --file/-f <file>, and kates ctx set --output <format> is now --default-output <format>. On both commands -o/--output is the global output format flag, as on every other command. kates ctx set warns when given --output without --default-output.

The commit body carries a BREAKING: line, as the repo's earlier breaking changes do.

Tests

Added:

  • TestScaffoldExport_OutputIsTheGlobalFlag: scaffold export quick-load --dir <tmp> -o json writes quick-load.yaml and no file named json, and sets the global output mode to json. -f mine.yaml writes mine.yaml.
  • TestCtxSet_DefaultOutputLeavesOutputGlobal:
    • ctx set lab --url … --default-output json -o json succeeds and stores json as the context's format, without the note.
    • ctx set staging --url … --output json stores table and prints the note naming --default-output.

On main's flags, the first test finds the template written to json, and the second does not parse.

Plan deviation: the plan's test says -o json "prints JSON". scaffold export has no JSON output, so with -o json it still prints its "Exported" line. JSON output for the commands that lack it is item 5.2, so this PR only frees the flag.

Run locally, passing:

  • cd cli && go test ./..., go test -race ./cmd, go vet ./....
  • scripts/check-book-style.sh, check-book-contrast.py, check-mermaid.sh, gen-version-matrix.sh --check, gen-chart-table.sh --check.
  • golangci-lint run --new-from-rev=origin/main ./...: 0 issues.
  • scripts/check-cli-style.sh and scripts/check-cli-compat.sh: OK.
  • The backend suite, which cli/** triggers (Build & Test): this PR touches nothing under kates/. ./mvnw test on main's kates/ tree ran 1,254 tests with 0 failures and 0 errors, once for all of Wave 1.

Skipped locally: govulncheck, as go.mod is unchanged; the book's HTML and PDF renders, since the book changes are flags inside code blocks.

CI only: ./mvnw verify with the *IT tests, the Kind and Docker jobs, CodeQL and Trivy.

…put flag

Two commands defined their own --output, which hid the global output format
flag:
- `kates test scaffold export quick-load -o json` wrote the template to a
  file named json.
- `kates ctx set foo --url … -o json` failed with "unknown shorthand flag",
  since ctx set's --output had no -o.

scaffold export names the file with --file/-f now, and ctx set takes the
context's default format with --default-output. -o and --output are the
global flag on both. ctx set notes on stderr when it gets --output without
--default-output, since such a script used to set the context's format and
now leaves it at table. The CLI help, `kates docs` entries, the book and the
tutorials use the new names.

BREAKING: `kates test scaffold export --output/-o` is now --file/-f, and
`kates ctx set --output` is now --default-output.
@bmscomp
bmscomp merged commit b2ddc2d into main Oct 18, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant