Skip to content

feat(cli): Declare a completion kind for every flag - #1759

Open
sentry-junior[bot] wants to merge 2 commits into
mainfrom
feat/cli-flag-completion
Open

sentry-junior[bot] wants to merge 2 commits into
mainfrom
feat/cli-flag-completion

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1751, which did this for positionals. Now every visible value-taking flag declares how shell completion handles it, and the build fails when a new flag doesn't.

What changed

  • test/lib/completion-coverage.test.ts now checks every visible, non-boolean flag on every visible command, not just positionals. A failure names the command and the flag. There is no allow-list.
  • Added a choice-list kind for comma-separated values. --fields id,ti<TAB> offers id,title, leaves out fields already chosen, and handles nested dot paths. buildFieldsFlag tags it once, and the generator writes each command's schema field names.
  • PARSER_TARGETS now covers the shared numeric, cursor, and limit parsers (text). It also covers fixed-value parsers such as sort, status, format, span depth, install method, HTTP method, and release channel. Their values come from the modules that define them; the lists are not duplicated.
  • --platform completes from the platform list. Path flags complete as files or directories. --query uses issue-query where the query is an issue search.
  • Every parse: String is replaced with a named, tagged parser from completion-target.ts. Added textParser(parse), and choiceParser now accepts an optional parse.
  • Moved the cursor parser and keywords from list-command.ts to arg-parsing.ts to avoid an import cycle.
  • Updated the "Shell completion" section of packages/cli/AGENTS.md to cover flags.
  • src/lib/completions.ts is untouched so it doesn't conflict with the parallel shell-script work.

Visible non-boolean flags: 466. Without a kind: 447 before, 0 after.

Verification

  • pnpm run typecheck, pnpm run lint, and node --test scripts/cli-lint-rules.test.mjs all pass.
  • Targeted vitest (complete, completion, introspect, argument-conventions, script): everything passes except 2 sandbox-only EACCES/EPERM failures in completions.test.ts.
  • npx vitest run test/commands: all 3036 tests pass.
  • Temporarily changing a flag back to String makes the coverage test fail.

Follow-ups

  • Entity completion for --environment, --release, --dist, --team, and bare-slug project flags. These are text for now.
  • About 115 --fields flags belong to commands that have no output schema, so they fall back to text.

--

View Session in Sentry

Every visible value-taking flag now says how shell completion handles
its value, and test/lib/completion-coverage.test.ts fails, naming the
command and flag, for any flag without a kind. There is no allow-list.

- --fields completes the output schema's field paths, nested ones in
  dot notation, one comma-separated item at a time, leaving out the
  fields already listed (new choice-list kind, choiceListParser).
- Shared parsers get kinds through PARSER_TARGETS: numberParser and
  sanitizeQuery complete nothing; parseCursorFlag, parseLogSort,
  parseSpanDepth, parseInstallationMethod, and parseReleaseChannel
  complete the values they accept. parseCursorFlag moves to
  arg-parsing.ts so completion-target.ts can import it without a cycle.
- A command's own validating parser keeps its checks when wrapped:
  choiceParser(values, parse) completes values (sort, status, format,
  method, datasets), textParser(parse) completes nothing (ports,
  limits, thresholds).
- Every parse: String flag uses a named parser: paths complete files or
  directories, --platform completes platforms, org list --account
  completes accounts, --scope/--features/--type complete their lists,
  --timezone completes tz names, and the rest are parseText.
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Oct 30, 2026 8:47pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 30, 2026
The viewer integration tests import `commands/local/server.ts`, which now
reaches `lib/arg-parsing.ts` through the tagged flag parsers in
`completion-target.ts`. That module imports the generated grammar, so a
fresh CI checkout with only the API schema generated failed to resolve
`org-project-target-grammar.js`.

`ensure-generated.mjs` now takes the groups to check, and the viewer test
asks for the schema and the grammar.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stopped at 41 files as it is apparent that you left many String parsers at parseText even though it is easy to see they are not random/free-form text. Let's do this properly.

until: {
kind: "parsed",
parse: String,
parse: parseText,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Based on the brief looks like this can be richer?

Comment on lines +26 to +32
parse: parseText,
brief: "Native integration ID, when multiple installations match",
optional: true,
},
app: {
kind: "parsed",
parse: String,
parse: parseText,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can these not be found through API calls etc?

field: {
kind: "parsed",
parse: String,
parse: parseText,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this actually has a strict format rather than free-form text?

into: {
kind: "parsed",
parse: String,
parse: parseText,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So rather than a random text, this actually needs to be an issue target?

This branch was successfully deployed

1 active deployment
Preview — c7939cfa Deployed Oct 30, 2026 by vercel[bot]
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