Skip to content

fix(cli): keep negative numeric values attached to their flag - #223

Merged
stewartjarod merged 1 commit into
mainfrom
fix/cli-parser-negative-flag-values
Oct 28, 2026
Merged

stewartjarod merged 1 commit into
mainfrom
fix/cli-parser-negative-flag-values

Conversation

@stewartjarod

Copy link
Copy Markdown
Contributor

Summary

In the shared arg parser, --limit -1 (space form) was read as a flag with no value, so the default applied silently, while --limit=-1 was parsed. email logs list --limit -1 hit this on main.

parseCliArgs
+  protectNegativeNumbers(argv)     # only tokens matching /^-\d+(\.\d+)?$/
+    --name -1  ->  --name=-1       # unless --name is a declared boolean or --no-*
+    short string flag (-d -1)      # placeholder, restored after mri
   mri(protectedArgs.argv)
+  restoreFlagValues(...)

Booleans never take a negative value; -h, -v, -y, -x and everything after -- are untouched.

Evidence

  • Before: --limit -1 -> flags {}; email logs list sent no limit.
    After: limit: "-1", and the command sends ?limit=-1, same as --limit=-1. Same for -5 and -0.5.
tests: 41 pass in the two new files (7 failed before the fix)
disabling the restore step -> 10 fail, restored -> pass
packages/cli   141 files / 2352 tests pass; tsc and biome clean

email logs list has no CLI-side --limit validation; the API rejects -1 (minimum: 1).

Merge Danger

Door: two-way

A bare -1 now reaches the positionals, so email logs get -1 looks up id -1 instead of the missing-input error. -d -1 now passes -1 as the domain; what domains add does with that was not checked.

Blast Radius: CLI

The parser is shared by every command. #219 edits the same file; a trial merge was clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GxJAQNUP4FKZHL1yzPDsGd

mri reads any "-<token>" as a cluster of short flags, so `--limit -1`
lost its value (the command fell back to the API default) and a bare
`-1` became a phantom flag `1`. `--limit=-1` already worked, so the two
forms behaved differently.

parseCliArgs now rewrites argv before mri sees it:
- `--name -1` becomes `--name=-1` when --name is a value flag (not a
  declared boolean and not a `--no-*` form). This covers declared string
  flags such as --limit and undeclared ones such as --offset.
- a bare `-1` is kept as a positional in `sub`.
- a short string flag given a negative number (`-d -1`, `-r -1`) gets
  the number back as its value, so it matches the long form.

Real flags are unaffected: only tokens matching /^-\d+(\.\d+)?$/ are
touched, so `-h`, `-v`, `-y` and `-x` keep their current meaning, boolean
flags never take a negative value, and everything after `--` is passed
through untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJAQNUP4FKZHL1yzPDsGd
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated
wraps-web Skipped Skipped Oct 28, 2026 6:32pm UTC
wraps-website Skipped Skipped Oct 28, 2026 6:32pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – wraps-web October 28, 2026 18:32 Inactive
@vercel
vercel Bot temporarily deployed to Preview – wraps-website October 28, 2026 18:32 Inactive
@stewartjarod
stewartjarod merged commit 2f491b0 into main Oct 28, 2026
17 of 20 checks passed
@stewartjarod
stewartjarod deleted the fix/cli-parser-negative-flag-values branch October 28, 2026 19:45

This branch was previously deployed

2 inactive deployments
Preview – wraps-website — 9da828ae Deployed Oct 28, 2026 by vercel[bot]
Preview – wraps-web — 9da828ae Deployed Oct 28, 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