-
Notifications
You must be signed in to change notification settings - Fork 0
feat: camelCaseValues transform and negated boolean handling #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a transform helper for use with map() that converts kebab-case
option keys to camelCase in the result values:
const parser = map(
opt.options({ 'output-dir': opt.string() }),
camelCaseValues,
);
// --output-dir ./dist → values.outputDir
Also fixes map() to properly compose transforms when chaining multiple
map() calls (was previously overwriting instead of chaining).
Includes:
- camelCaseValues transform function
- KebabToCamel and CamelCaseKeys type utilities
- Tests for the new functionality
- README documentation
- Updated transforms.ts example to demonstrate usage
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
All boolean options now automatically support a negated form to explicitly
set the option to false:
--verbose → { verbose: true }
--no-verbose → { verbose: false }
(neither) → { verbose: default or undefined }
If both --flag and --no-flag are specified, throws a HelpError with a
clear message about the conflict.
In help output, booleans with default: true display as --no-<flag>
since that's how users would turn them off. Short aliases are not shown
for negated forms.
Includes:
- Parser support for processing --no-* flags
- Help text updates for default:true booleans
- Comprehensive tests for both parser and help
- README documentation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds two new features to the bargs CLI parser: automatic boolean negation support (--no-<flag>) and a camelCaseValues transform for converting kebab-case option keys to camelCase.
Key changes:
- Boolean options now automatically support
--no-<flag>syntax to explicitly set them to false, with conflict detection when both forms are used - New
camelCaseValuestransform function for converting kebab-case keys to camelCase with full type safety - Fixed
map()combinator to properly compose transforms when chaining instead of overwriting them
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/parser.test.ts | Comprehensive test suite for boolean negation feature covering basic usage, conflicts, defaults, and edge cases |
| test/help.test.ts | Tests for help text display of negated booleans, ensuring --no-<flag> shown for default: true options |
| test/combinators.test.ts | Tests for camelCaseValues transform including kebab-to-camel conversion and integration with map() |
| src/parser.ts | Implements boolean negation by adding no-<name> variants to parseArgs config and processing conflicts |
| src/help.ts | Updates help formatting to display --no-<flag> for booleans with default: true without short aliases |
| src/bargs.ts | Adds camelCaseValues transform and fixes map() to compose transforms via composeTransform helper |
| src/types.ts | Adds KebabToCamel and CamelCaseKeys type utilities for type-safe camelCase transformations |
| src/index.ts | Exports new camelCaseValues function and CamelCaseKeys/KebabToCamel types |
| examples/transforms.ts | Demonstrates chained usage of camelCaseValues with additional transforms |
| README.md | Documents both boolean negation feature and camelCaseValues transform with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move CamelCaseKeys type to correct alphabetical position per linting rules - Update kebabToCamel regex to handle uppercase letters after hyphens 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>

feat: add camelCaseValues transform for kebab-to-camel option keys
Adds a transform helper for use with map() that converts kebab-case
option keys to camelCase in the result values:
Also fixes
map()to properly compose transforms when chaining multiplemap()calls (was previously overwriting instead of chaining).Includes:
camelCaseValuestransform functionKebabToCamelandCamelCaseKeystype utilitiestransforms.tsexample to demonstrate usagefeat: add automatic --no- support for boolean options
All boolean options now automatically support a negated form to explicitly
set the option to false:
If both
--flagand--no-flagare specified, throws a HelpError with aclear message about the conflict.
In help output, booleans with
default: truedisplay as--no-<flag>since that's how users would turn them off. Short aliases are not shown
for negated forms.
Includes:
--no-*flagsdefault:truebooleansREADMEdocumentation