Repository navigation
fix(cli): keep negative numeric values attached to their flag - #223
Merged
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=-1was parsed.email logs list --limit -1hit this onmain.Booleans never take a negative value;
-h,-v,-y,-xand everything after--are untouched.Evidence
--limit -1->flags {};email logs listsent nolimit.After:
limit: "-1", and the command sends?limit=-1, same as--limit=-1. Same for-5and-0.5.email logs listhas no CLI-side--limitvalidation; the API rejects-1(minimum: 1).Merge Danger
Door: two-way
A bare
-1now reaches the positionals, soemail logs get -1looks up id-1instead of the missing-input error.-d -1now passes-1as the domain; whatdomains adddoes 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