Skip to content

fix(cli): reject unrecognized flags instead of treating them as issue ids (#2) - #4

Merged
bougyman merged 1 commit into
mainfrom
issue-2
Aug 8, 2026
Merged

fix(cli): reject unrecognized flags instead of treating them as issue ids (#2)#4
bougyman merged 1 commit into
mainfrom
issue-2

Conversation

@bougyman

@bougyman bougyman commented Aug 8, 2026

Copy link
Copy Markdown
Member

issue list/take/update all set allow_unknown_args: true so bare tokens
(e.g. CRY-1) can be captured as issue ids via result.unknown - Optimus
has no type: :array equivalent for positional args. That same bucket
also silently swallowed any unrecognized flag (a typo, or a real flag
the subcommand just doesn't have, like --mine on issue list), which
then got looked up as a literal issue id instead of erroring - a raw
%Ash.Error.Unknown{} dump reaching the user.

run/3 now filters result.unknown for anything flag-shaped before ever
calling the command, returning a clean {:smells_bad, "unrecognized
option(s): ..."} (exit 22) instead. Every other subcommand already has
this covered by Optimus's own parser (allow_unknown_args: false
rejects unknown args before we ever see a parse_result), so this only
ever fires for the three subcommands that needed the escape hatch.

Per the issue: --mine itself is intentionally not being added -
--no-mine already covers it (--mine is the implied default).

… ids (#2)

issue list/take/update all set allow_unknown_args: true so bare tokens
(e.g. CRY-1) can be captured as issue ids via result.unknown - Optimus
has no type: :array equivalent for positional args. That same bucket
also silently swallowed any unrecognized flag (a typo, or a real flag
the subcommand just doesn't have, like --mine on issue list), which
then got looked up as a literal issue id instead of erroring - a raw
%Ash.Error.Unknown{} dump reaching the user.

run/3 now filters result.unknown for anything flag-shaped before ever
calling the command, returning a clean {:smells_bad, "unrecognized
option(s): ..."} (exit 22) instead. Every other subcommand already has
this covered by Optimus's own parser (allow_unknown_args: false
rejects unknown args before we ever see a parse_result), so this only
ever fires for the three subcommands that needed the escape hatch.

Per the issue: --mine itself is intentionally not being added -
--no-mine already covers it (--mine is the implied default).
Copilot AI lite review requested due to automatic review settings August 8, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown

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 improves linear-cli’s handling of subcommands that enable allow_unknown_args: true (to capture bare issue IDs) by rejecting flag-shaped unknown tokens up front, preventing typos/unimplemented flags from being interpreted as issue identifiers and causing confusing Ash error dumps.

Changes:

  • Added reject_unknown_flags/1 gating in run/3 to turn unknown -/---prefixed tokens into a clean {:smells_bad, "unrecognized option(s): ..."} error (exit 22) before any command/API call.
  • Added an ExUnit regression test ensuring issue list --mine errors clearly instead of being treated as an issue id.

Reviewed changes

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

File Description
app/lib/linear_cli/cli.ex Filters result.unknown for flag-shaped tokens and routes them through the existing :smells_bad error handling (exit 22).
app/test/linear_cli/cli_test.exs Adds regression coverage for the issue list --mine case to ensure a clear, user-facing error.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bougyman
bougyman merged commit e697ff6 into main Aug 8, 2026
3 checks passed
@bougyman
bougyman deleted the issue-2 branch August 8, 2026 16:55
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