Skip to content

feat: argparse#3213

Open
peter-jerry-ye wants to merge 5 commits intomainfrom
zihang/argparse
Open

feat: argparse#3213
peter-jerry-ye wants to merge 5 commits intomainfrom
zihang/argparse

Conversation

@peter-jerry-ye
Copy link
Collaborator

@peter-jerry-ye peter-jerry-ye commented Feb 10, 2026

This PR adds an arg parser that is inspired by clap but with reduced API because we want to focus on the clarity of the behavior. A lot of extra checks were imposed.

The API of this PR is roughly determined, but the internal implementation can still be improved drastically.

@FlyCloudC Do you think you would like to give it a review in terms of the API? (I know the internal implementation is a bit messy).


Open with Devin

@peter-jerry-ye peter-jerry-ye force-pushed the zihang/argparse branch 2 times, most recently from 6280975 to 2ede161 Compare February 10, 2026 02:59
@coveralls
Copy link
Collaborator

coveralls commented Feb 10, 2026

Pull Request Test Coverage Report for Build 2640

Details

  • 798 of 873 (91.41%) changed or added relevant lines in 15 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 95.68%

Changes Missing Coverage Covered Lines Changed/Added Lines %
argparse/command.mbt 40 41 97.56%
argparse/parser_lookup.mbt 28 30 93.33%
argparse/parser_suggest.mbt 35 37 94.59%
argparse/help_render.mbt 140 143 97.9%
argparse/parser.mbt 143 149 95.97%
argparse/parser_positionals.mbt 34 43 79.07%
argparse/parser_validate.mbt 145 159 91.19%
argparse/parser_globals_merge.mbt 84 103 81.55%
argparse/parser_values.mbt 76 95 80.0%
Totals Coverage Status
Change from base Build 2631: -0.3%
Covered Lines: 12712
Relevant Lines: 13286

💛 - Coveralls

@peter-jerry-ye peter-jerry-ye force-pushed the zihang/argparse branch 3 times, most recently from b62c1c9 to b286791 Compare February 13, 2026 10:05
@peter-jerry-ye peter-jerry-ye marked this pull request as ready for review February 14, 2026 10:02
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b59017e8e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +147 to +151
let parent_count = parent.counts.get(name).unwrap_or(0)
let child_count = child.counts.get(name).unwrap_or(0)
let total = parent_count + child_count
parent.counts[name] = total
parent.flags[name] = total > 0

Choose a reason for hiding this comment

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

P1 Badge Preserve negated global count flags when merging argv

When a global Count flag is set before a subcommand and negated after it (for example --verbose run --no-verbose), the child parse records a reset (count=0), but this merge branch always adds parent and child counts. That turns an explicit later negation into a non-zero total and reports the flag as enabled, which is the opposite of in-command --no-... behavior; the child argv reset needs to override additive merging.

Useful? React with 👍 / 👎.

Comment on lines +111 to +113
let choose_child = has_child &&
(!has_parent || prefer_child_source(parent_source, child_source))
if choose_child {

Choose a reason for hiding this comment

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

P2 Badge Enforce duplicate Set options across subcommand boundaries

This path lets a child argv value replace a parent argv value for non-multi global options, so Set options passed both before and after a subcommand (e.g. --mode a run --mode b) are accepted instead of raising the duplicate-use error enforced elsewhere. That makes duplicate validation depend on token placement rather than argument definition and bypasses check_duplicate_set_occurrence for global options.

Useful? React with 👍 / 👎.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

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.

3 participants