Skip to content

feat: Shell completion generation #22

@boneskull

Description

@boneskull

Summary

Add support for generating shell completion scripts (bash, zsh, fish) similar to yargs' .completion() feature.

Use Case

When migrating from yargs to bargs, shell completion is one of the features that doesn't have a direct equivalent. Power users who rely on tab completion for CLI tools would benefit from this.

Proposed API

Something like:

const cli = bargs('mytool')
  .command('build', buildParser, buildHandler)
  .command('test', testParser, testHandler);

// Generate completion script
cli.completionScript('bash'); // or 'zsh', 'fish'

Or perhaps a built-in completion command that outputs the appropriate script:

mytool completion bash >> ~/.bashrc
mytool completion zsh >> ~/.zshrc

Priority

Low - This is a nice-to-have for power users, not a blocker for CLI functionality.


Feature request from migrating modestbench from yargs to bargs 🎸

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions