Skip to content

feat: Allowing preserving double dashes for variadic args (#229) - #417

Merged
jdx merged 1 commit into
jdx:mainfrom
alcroito:preserve_double_dashes
Jan 14, 2026
Merged

feat: Allowing preserving double dashes for variadic args (#229)#417
jdx merged 1 commit into
jdx:mainfrom
alcroito:preserve_double_dashes

Conversation

@alcroito

@alcroito alcroito commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Previously, all double dash tokens were discarded when parsed.

A new preserve option has been added to the double_dash setting for arguments. When set to preserve on a variadic argument, any double dash tokens (--) encountered while parsing will be retained as part of the argument's value.

Just like for non-preserve behavior, enable_flags processing is disabled for preserve behavior as well. That's because any potential common flags like --verbose should be captured inside the variadic arg, rather than being treated as flags.

Added tests to verify the new behavior.

Fixes #229


Note

Introduces a new double_dash behavior to retain -- tokens in variadic args and updates parsing, spec, and docs accordingly.

  • Adds SpecDoubleDashChoices::Preserve and serializes double_dash when automatic or preserve
  • Parser: -- always disables flag parsing; when next arg is variadic with double_dash=preserve, the -- token is kept as an arg value
  • Builder: SpecArgBuilder::double_dash(...) to set behavior programmatically
  • Docs: updates arg.md with double_dash="preserve" example
  • Tests: new cases covering preserved/skipped --, multiple args, and edge cases

Written by Cursor Bugbot for commit f1ac35b. This will update automatically on new commits. Configure here.

@alcroito
alcroito force-pushed the preserve_double_dashes branch from 921ee18 to 4b3ea15 Compare January 14, 2026 15:30
@codecov

codecov Bot commented Jan 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.42857% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.08%. Comparing base (fc9a6da) to head (f1ac35b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/parse.rs 90.22% 6 Missing and 7 partials ⚠️
lib/src/spec/arg.rs 0.00% 1 Missing and 2 partials ⚠️
lib/src/spec/builder.rs 25.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
- Coverage   52.08%   50.08%   -2.01%     
==========================================
  Files          47       47              
  Lines        5894     6100     +206     
  Branches     5894     6100     +206     
==========================================
- Hits         3070     3055      -15     
- Misses       1438     1513      +75     
- Partials     1386     1532     +146     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jdx

jdx commented Jan 14, 2026

Copy link
Copy Markdown
Owner

bugbot run

Comment thread lib/src/spec/arg.rs
Previously, all double dash tokens were discarded when parsed.

A new `preserve` option has been added to the `double_dash` setting
for arguments. When set to `preserve` on a variadic argument, any
double dash tokens (`--`) encountered while parsing will be retained
as part of the argument's value.

Just like for non-preserve behavior, `enable_flags` processing is
disabled for preserve behavior as well. That's because any potential
common flags like `--verbose` should be captured inside the variadic
arg, rather than being treated as flags.

Added tests to verify the new behavior.

Fixes jdx#229
@alcroito
alcroito force-pushed the preserve_double_dashes branch from 4b3ea15 to f1ac35b Compare January 14, 2026 17:14
@jdx

jdx commented Jan 14, 2026

Copy link
Copy Markdown
Owner

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no bugs!

@jdx
jdx merged commit 7b0bcab into jdx:main Jan 14, 2026
8 of 9 checks passed
jdx pushed a commit that referenced this pull request Jan 14, 2026
## [2.12.0](https://github.com/jdx/usage/compare/v2.11.0..v2.12.0) -
2026-01-14

### 🚀 Features

- Allowing preserving double dashes for variadic args by
[@alcroito](https://github.com/alcroito) in
[#417](#417)

### 📦️ Dependency Updates

- replace dependency @tsconfig/node18 with @tsconfig/node20 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#411](#411)
- update amannn/action-semantic-pull-request action to v6 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#412](#412)
- replace dependency @tsconfig/node20 with @tsconfig/node22 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#415](#415)
- update rust crate clap to v4.5.54 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#416](#416)

### New Contributors

- @alcroito made their first contribution in
[#417](#417)
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 17, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [usage](https://github.com/jdx/usage) | minor | `2.11.0` → `2.12.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/usage (usage)</summary>

### [`v2.12.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#2120---2026-01-14)

[Compare Source](jdx/usage@v2.11.0...v2.12.0)

##### 🚀 Features

- Allowing preserving double dashes for variadic args by [@&#8203;alcroito](https://github.com/alcroito) in [#&#8203;417](jdx/usage#417)

##### 📦️ Dependency Updates

- replace dependency [@&#8203;tsconfig/node18](https://github.com/tsconfig/node18) with [@&#8203;tsconfig/node20](https://github.com/tsconfig/node20) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;411](jdx/usage#411)
- update amannn/action-semantic-pull-request action to v6 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;412](jdx/usage#412)
- replace dependency [@&#8203;tsconfig/node20](https://github.com/tsconfig/node20) with [@&#8203;tsconfig/node22](https://github.com/tsconfig/node22) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;415](jdx/usage#415)
- update rust crate clap to v4.5.54 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;416](jdx/usage#416)

##### New Contributors

- [@&#8203;alcroito](https://github.com/alcroito) made their first contribution in [#&#8203;417](jdx/usage#417)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MS4yIiwidXBkYXRlZEluVmVyIjoiNDIuODEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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.

arg removes all double dashes from the arguments, even after the first one

2 participants