Skip to content

fix(cli): exit 0 for bare group commands to match Go cobra parity#5827

Merged
Coly010 merged 1 commit into
developfrom
columferry/cli-1906-legacy-cli-bare-group-commands-no-subcommand-exit-1-instead
Jul 8, 2026
Merged

fix(cli): exit 0 for bare group commands to match Go cobra parity#5827
Coly010 merged 1 commit into
developfrom
columferry/cli-1906-legacy-cli-bare-group-commands-no-subcommand-exit-1-instead

Conversation

@Coly010

@Coly010 Coly010 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What changed

Invoking a legacy-shell group command that has subcommands but is itself not runnable — e.g. supabase branches, supabase completion — with no subcommand and no --help exited 1 in the TS legacy shell. Go's cobra CLI exits 0 for the identical invocation: a non-Runnable() command with no RunE internally returns flag.ErrHelp, which cobra's ExecuteC() maps to "print help, return nil error". Only explicit --help got exit 0 before this fix; the bare/missing-subcommand form did not, even though the printed help text was identical in both cases.

CliError.ShowHelp (in effect/unstable/cli) already declares the correct exit code via Effect's own Runtime.errorExitCode marker (0 for a clean ShowHelp with no errors, 1 otherwise) — apps/cli/src/shared/cli/run.ts now delegates to Runtime.getErrorExitCode(Cause.squash(cause)) instead of hand-rolling ShowHelp classification, which is simpler and tracks the library's own source of truth for any future CliError additions.

Also added an integration test driving the real legacyBranchesCommand through Command.runWith (confirming the actual ShowHelp cause shape), and an e2e test asserting the real compiled-binary exit code, since this bug is specifically about the real OS process exit code.

Known related (not fixed here)

A typo'd subcommand under a group (e.g. supabase branches bogus) still exits 1 where Go cobra exits 0 for a non-root command — this is pre-existing on develop, not a regression from this change, and out of scope for this fix. Filed as a follow-up.

Fixes CLI-1906

Invoking a legacy-shell group command with subcommands but no
subcommand and no --help (e.g. `supabase branches`, `supabase
completion`) exited 1. Go's cobra CLI exits 0 for the identical
invocation: a non-Runnable command with no RunE returns flag.ErrHelp
internally, which ExecuteC() maps to "print help, return nil error".

CliError.ShowHelp already declares the correct exit code via Effect's
own Runtime.errorExitCode marker (0 for a clean ShowHelp with no
errors, 1 otherwise), so run.ts now delegates to
Runtime.getErrorExitCode(Cause.squash(cause)) instead of hand-rolling
ShowHelp classification.

Fixes CLI-1906
@Coly010

Coly010 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 48b09a2675

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Coly010 Coly010 self-assigned this Jul 8, 2026
@Coly010 Coly010 marked this pull request as ready for review July 8, 2026 11:33
@Coly010 Coly010 requested a review from a team as a code owner July 8, 2026 11:33
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@48b09a2675cc5a23847c91599bab96b5ac5191c9

Preview package for commit 48b09a2.

@Coly010 Coly010 added this pull request to the merge queue Jul 8, 2026
Merged via the queue into develop with commit c0ed40c Jul 8, 2026
27 checks passed
@Coly010 Coly010 deleted the columferry/cli-1906-legacy-cli-bare-group-commands-no-subcommand-exit-1-instead branch July 8, 2026 15:33
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