Skip to content

feat(cli): show root help on bare invocation#9

Merged
vladtara merged 1 commit into
mainfrom
005-cli-default-help
Jun 28, 2026
Merged

feat(cli): show root help on bare invocation#9
vladtara merged 1 commit into
mainfrom
005-cli-default-help

Conversation

@vladtara

Copy link
Copy Markdown
Contributor

Summary

Make a bare gskill invocation print the root help screen to stdout and exit 0, identical to gskill --help and gskill -h. Previously gskill printed the version, and gskill --help printed help but exited 2 (a latent bug, now fixed). Invalid input and failing commands still exit non-zero.

Spec lives under specs/005-cli-default-help/ (kept untracked per project convention).

Changes

  • internal/cli/root.go: drop default:"1" from the version command; rewrite an empty arg list to --help; capture Kong's Exit callback into helpRequested and return CodeOK (0) before the parse-error branch. Routing the bare case through Kong's own --help flag makes the three help outputs byte-identical for free.
  • internal/cli/root_test.go: replace the obsolete TestRun_BareInvocationRunsDefaultVersion (which pinned the old bare->version default) with tests for bare/--help/-h -> help + exit 0, byte-identical output, commands+flags listed, and unknown-command -> non-zero.

Behavior

Invocation stdout stderr exit
gskill root help empty 0
gskill --help / -h root help (identical) empty 0
gskill version version line empty 0
gskill <unknown> / --badflag empty diagnostic 2

Verification

  • Test-first (Red->Green): the bare-help test was seen failing before the root.go change, passing after.
  • ./scripts/verify.sh exits 0 — fmt, vet, golangci-lint, -race tests, coverage floor, govulncheck (0 vulns), gitleaks (0 leaks).
  • Manual quickstart checks all pass; the three help invocations are byte-identical.
  • Generated reference docs (docs/reference/commands.md) unchanged.

Running `gskill` with no arguments now prints the root help screen to
stdout and exits 0, identical to `gskill --help` and `gskill -h`, instead
of printing the version. This also fixes a latent bug where `gskill --help`
printed help but exited 2.

Drop the `default:"1"` tag from the version command, rewrite an empty
argument list to `--help`, and capture Kong's Exit callback so a help
request resolves to exit code 0 before the parse-error branch. Invalid
flags and unknown commands still exit non-zero, and `gskill version`
still prints the version.
Copilot AI review requested due to automatic review settings June 28, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CLI’s default behavior so that invoking gskill with no arguments prints the root help text to stdout and exits 0, matching gskill --help / gskill -h. It also fixes the prior latent bug where --help exited with code 2.

Changes:

  • Removed the version command’s default selection so “no args” is no longer implicitly version.
  • Rewrites a truly bare invocation (len(args)==0) to --help to ensure byte-identical help output across all help entrypoints.
  • Updates tests to assert help output/exit code behavior (including byte-identical output) and to keep unknown-command behavior non-zero.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/cli/root.go Routes bare invocation through Kong’s --help path and treats help as success (exit 0), removing the default version command selection.
internal/cli/root_test.go Replaces the old “bare runs version” test with coverage for bare/--help/-h help output, exit codes, and unknown-command non-zero behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vladtara
vladtara merged commit 33de268 into main Jun 28, 2026
9 checks passed
@vladtara
vladtara deleted the 005-cli-default-help branch June 29, 2026 16:31
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.

2 participants