Repository navigation
fix(cli): scaffold export and ctx set stop hiding the global -o/--output flag - #399
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/--outputoutput-format flag. On main (6f4cf61):kates test scaffold export quick-load -o jsonwrites the template to a file namedjson(cli/cmd/scaffold.go:229,StringVarP(…, "output", "o", …)).kates ctx set foo --url … -o jsonfails withunknown 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:--default-output.ctx setnotes on stderr when it gets--outputwithout--default-output. A script written for the old flag now sets this command's output format and leaves the context attable, so it should hear about it.cli/cmd/data/doc_entries.yaml(kates docs): thectx setflag and example.10-cli-reference.md,13-scenario-files.md) and the tutorials (02-all-test-types.md,06-cicd-integration.md): 8scaffold export … -o <file>examples become-f <file>.-oand--outputon both commands are now the global flag.Release note
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 jsonwritesquick-load.yamland no file namedjson, and sets the global output mode to json.-f mine.yamlwritesmine.yaml.TestCtxSet_DefaultOutputLeavesOutputGlobal:ctx set lab --url … --default-output json -o jsonsucceeds and storesjsonas the context's format, without the note.ctx set staging --url … --output jsonstorestableand 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 exporthas no JSON output, so with-o jsonit 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.shandscripts/check-cli-compat.sh: OK.cli/**triggers (Build & Test): this PR touches nothing underkates/../mvnw teston main'skates/tree ran 1,254 tests with 0 failures and 0 errors, once for all of Wave 1.Skipped locally:
govulncheck, asgo.modis unchanged; the book's HTML and PDF renders, since the book changes are flags inside code blocks.CI only:
./mvnw verifywith the*ITtests, the Kind and Docker jobs, CodeQL and Trivy.