Skip to content

Conversation

@boneskull
Copy link
Owner

@boneskull boneskull commented Jan 6, 2026

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:

  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

feat: add automatic --no- support for boolean options

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

boneskull and others added 2 commits January 6, 2026 13:31
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>
Copilot AI review requested due to automatic review settings January 6, 2026 22:06
Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

Copilot AI left a 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 camelCaseValues transform 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>
@boneskull boneskull merged commit aa94953 into main Jan 6, 2026
9 checks passed
@boneskull boneskull deleted the feats branch January 6, 2026 22:41
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.

2 participants