You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: add merge() combinator for combining parsers
Adds a new merge() function that combines multiple parsers into one,
providing a cleaner alternative to the callable parser syntax:
// With merge() - linear, readable
merge(
opt.options({ priority: opt.enum(['low', 'medium', 'high']) }),
pos.positionals(pos.string({ name: 'task' })),
)
// Callable syntax - inside-out, confusing )(
pos.positionals(...)(opt.options(...))
The merge() function:
- Accepts 2-4 parsers (with overloads for type safety)
- Merges option schemas (later overrides earlier)
- Concatenates positional schemas
- Chains transforms from merged parsers
Updated README to document merge() and use it in examples.
BREAKING CHANGE: none, additive only
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
The `handle(parser, fn)` function is exported for advanced use cases where you need to create a `Command` object outside the fluent builder. It's mostly superseded by `.command(name, parser, handler)`.
549
566
567
+
## Dependencies
568
+
569
+
**bargs** has zero (0) dependencies. Only Node.js v22+.
570
+
550
571
## Motivation
551
572
552
573
I've always reached for [yargs](https://github.com/yargs/yargs) in my CLI projects. However, I find myself repeatedly doing the same things; I have a sort of boilerplate in my head, ready to go (`requiresArg: true` and `nargs: 1`, amirite?). I don't want boilerplate in my head. I wanted to distill my chosen subset of yargs' behavior into a composable API. And so **bargs** was begat.
0 commit comments