Skip to content

Conversation

@boneskull
Copy link
Owner

Add command aliases using a hybrid API that supports both simple string
descriptions (backward compatible) and a CommandOptions object with
aliases array.

Features:

  • Aliases work for both leaf commands and nested command groups
  • Help output displays aliases in dimmer styling alongside command names
  • Alias conflicts are detected at registration time
  • New 'commandAlias' theme color for customizable alias styling

API:
// Simple (unchanged)
.command('add', parser, handler, 'Add an item')

// With aliases
.command('add', parser, handler, {
description: 'Add an item',
aliases: ['a', 'new']
})

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Add command aliases using a hybrid API that supports both simple string
descriptions (backward compatible) and a CommandOptions object with
aliases array.

Features:
- Aliases work for both leaf commands and nested command groups
- Help output displays aliases in dimmer styling alongside command names
- Alias conflicts are detected at registration time
- New 'commandAlias' theme color for customizable alias styling

API:
  // Simple (unchanged)
  .command('add', parser, handler, 'Add an item')

  // With aliases
  .command('add', parser, handler, {
    description: 'Add an item',
    aliases: ['a', 'new']
  })

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 8, 2026 07:14
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 command alias support to the bargs CLI framework, allowing commands to be invoked using alternative names (e.g., ls as an alias for list). The implementation uses a hybrid API that maintains backward compatibility with existing string descriptions while supporting a new CommandOptions object that includes an aliases array.

Key changes:

  • Command aliases are registered and resolved for both leaf commands and nested command groups
  • Help output displays aliases alongside command names with dimmer styling
  • Alias conflicts are detected and reported at registration time

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types.ts Adds CommandOptions interface to support aliases and updates command registration signatures
src/bargs.ts Implements alias registration, resolution logic, and conflict detection
src/help.ts Updates help generation to display command aliases with appropriate styling
src/theme.ts Adds commandAlias theme color for styling aliases differently from command names
src/index.ts Exports CommandOptions type for public API
test/bargs.test.ts Adds comprehensive test coverage for alias functionality including resolution and error cases
examples/tasks.ts Demonstrates alias usage in a practical task management example
examples/nested-commands.ts Demonstrates aliases in nested command groups

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

boneskull and others added 2 commits January 8, 2026 21:21
Changed error message from 'is already registered for command' to
'conflicts with existing command name' for clarity when an alias
conflicts with an existing command name.

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed usage documentation in nested-commands.ts that had lines
incorrectly merged together, making the examples unreadable.
Used @example with fenced code block to prevent prettier from
reflowing the command examples.

Co-Authored-By: Claude <noreply@anthropic.com>
@boneskull boneskull merged commit ece5b81 into main Jan 9, 2026
7 checks passed
@boneskull boneskull deleted the command-aliases branch January 9, 2026 05:25
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