Skip to content

fix(cli-framework): show global options in subcommand --help#4424

Merged
saddlepaddle merged 1 commit into
mainfrom
superset-cli-json-help
May 11, 2026
Merged

fix(cli-framework): show global options in subcommand --help#4424
saddlepaddle merged 1 commit into
mainfrom
superset-cli-json-help

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 11, 2026

Summary

  • --json, --quiet, and --api-key were declared as globals in cli.config.ts but only rendered under superset --helpsuperset <group> --help and superset <group> <cmd> --help silently dropped them because generateGroupHelp / generateCommandHelp took _globals (underscored, unused).
  • Render the globals section (and a --help, -h line) in both group and command help, matching the root help format.

Test plan

  • superset --help still shows Global options (unchanged behavior)
  • superset auth --help now lists --json, --quiet, --api-key
  • superset auth login --help now lists them
  • superset tasks list --help now lists them
  • bun run lint clean
  • bun run typecheck --filter @superset/cli-framework passes

Summary by cubic

Fixes CLI help so global options show for subcommands. superset <group> --help and superset <group> <cmd> --help now display the Global options section (--json, --quiet, --api-key) and a --help, -h line, matching the root help.

Written for commit d65e847. Summary will update on new commits.

Summary by CodeRabbit

  • Improvements
    • Enhanced CLI command help text to conditionally display available global options, providing clearer documentation and improving command discovery for users.

Review Change Stack

Globals like --json were only listed under `superset --help`, not in
group/command help (e.g. `superset auth --help`, `superset tasks list
--help`). The `_globals` param was underscored/unused. Render it.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6ac9ff12-f6fa-4e10-9e5a-8fbb7ca37cb7

📥 Commits

Reviewing files that changed from the base of the PR and between f4f6c6c and d65e847.

📒 Files selected for processing (1)
  • packages/cli-framework/src/help.ts

📝 Walkthrough

Walkthrough

The PR exposes globals as a public parameter in CLI help generators and adds conditional rendering of global options sections. Function signatures for generateGroupHelp and generateCommandHelp rename _globals to globals, and both functions now append formatted global options when the parameter is provided and non-empty.

Changes

Global Options Help Rendering

Layer / File(s) Summary
Function Signature Updates
packages/cli-framework/src/help.ts
generateGroupHelp and generateCommandHelp rename optional parameter from _globals to globals, exposing it as a public API contract.
Global Options Conditional Rendering
packages/cli-framework/src/help.ts
Both functions conditionally append formatted "Global options" sections using formatOptions(globals) only when globals is defined and non-empty.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A whisper through the CLI brush,
Global options now in public rush,
Parameters renamed, clean and bright,
Conditional rendering sets things right!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch superset-cli-json-help

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR fixes generateGroupHelp and generateCommandHelp in help.ts, which both accepted a globals parameter (previously named _globals) but never used it, silently omitting --json, --quiet, and --api-key from sub-command --help output. The fix renames the parameter and adds the same "Global options:" rendering block and --help, -h footer already present in generateRootHelp.

  • generateGroupHelp and generateCommandHelp now render global flags and the --help, -h hint, matching root-level help format.
  • The guard Object.keys(globals).length > 0 is slightly stricter than the bare if (globals) check used in generateRootHelp, which avoids printing an empty "Global options:" header.

Confidence Score: 4/5

Safe to merge; the change is display-only and does not affect CLI behavior or option parsing.

The fix is narrowly scoped to help text rendering. The one rough edge is that generateCommandHelp still omits [options] from the usage line when a command has no local options but does have globals — now that globals are rendered, that usage line can silently understate what is available. Everything else correctly mirrors the existing generateRootHelp pattern.

packages/cli-framework/src/help.ts — specifically the [options] suffix logic in generateCommandHelp

Important Files Changed

Filename Overview
packages/cli-framework/src/help.ts Renames unused _globals param to globals in generateGroupHelp and generateCommandHelp, then renders a "Global options:" block and a --help, -h line — matching the root help output.

Comments Outside Diff (1)

  1. packages/cli-framework/src/help.ts, line 124-126 (link)

    P2 The usage line appends [options] only when the command has local options, so a command with no local options but with globals will display a usage like Usage: superset auth login — even though global options are now shown below it. A reader following the usage line wouldn't know options are accepted at all.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/cli-framework/src/help.ts
    Line: 124-126
    
    Comment:
    The usage line appends `[options]` only when the command has local options, so a command with no local options but with globals will display a usage like `Usage: superset auth login` — even though global options are now shown below it. A reader following the usage line wouldn't know options are accepted at all.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/cli-framework/src/help.ts:124-126
The usage line appends `[options]` only when the command has local options, so a command with no local options but with globals will display a usage like `Usage: superset auth login` — even though global options are now shown below it. A reader following the usage line wouldn't know options are accepted at all.

```suggestion
	if (
		(node.options && Object.keys(node.options).length > 0) ||
		(globals && Object.keys(globals).length > 0)
	) {
		usage += " [options]";
	}
```

Reviews (1): Last reviewed commit: "fix(cli-framework): show global options ..." | Re-trigger Greptile

@saddlepaddle saddlepaddle merged commit 24e5e1c into main May 11, 2026
15 of 16 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

@saddlepaddle saddlepaddle mentioned this pull request May 12, 2026
3 tasks
saddlepaddle added a commit that referenced this pull request May 12, 2026
Changes since v0.2.14:

- workspaces: `superset workspaces list` now accepts `--project` and
  `--search` filters, matching the desktop list view. (#4455)
- cli-framework: `--help` on a subcommand now shows the global options
  (e.g. `--json`, `--quiet`, `--api-key`) instead of hiding them. (#4424)
- host-service: attachment upload no longer rejects unknown mediaType
  values returned by some hosts. (#4439)
- host-service: PR fetch is now per-branch, avoiding 504s on repos with
  large numbers of open PRs. (#4268)

Push cli-v0.2.15 after this lands to fire the release pipeline.
MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request May 25, 2026
…t-sh#4424)

Globals like --json were only listed under `superset --help`, not in
group/command help (e.g. `superset auth --help`, `superset tasks list
--help`). The `_globals` param was underscored/unused. Render it.
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