File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -644,6 +644,67 @@ Available theme color slots:
644644> [ !TIP]
645645> You don't need to specify all color slots. Missing colors fall back to the default theme.
646646
647+ ## Shell Completion
648+
649+ ** bargs** can generate shell completion scripts for bash, zsh, and fish. Enable it with the ` completion ` option:
650+
651+ ``` typescript
652+ bargs (' my-cli' , {
653+ completion: true ,
654+ version: ' 1.0.0' ,
655+ });
656+ ```
657+
658+ Then generate and install the completion script for your shell:
659+
660+ ### Bash
661+
662+ ``` bash
663+ # Add to ~/.bashrc (or ~/.bash_profile on macOS)
664+ my-cli --completion-script bash >> ~ /.bashrc
665+ source ~ /.bashrc
666+ ```
667+
668+ ### Zsh
669+
670+ ``` bash
671+ # Add to ~/.zshrc
672+ my-cli --completion-script zsh >> ~ /.zshrc
673+ source ~ /.zshrc
674+
675+ # Or save to a file in your $fpath
676+ my-cli --completion-script zsh > ~ /.zsh/completions/_my-cli
677+ ```
678+
679+ ### Fish
680+
681+ ``` bash
682+ # Save to completions directory
683+ my-cli --completion-script fish > ~ /.config/fish/completions/my-cli.fish
684+ ```
685+
686+ ### What Gets Completed
687+
688+ Once installed, pressing <kbd >Tab</kbd > will complete:
689+
690+ - ** Commands and subcommands** (including nested commands and aliases)
691+ - ** Options** (` --verbose ` , ` -v ` , ` --no-verbose ` for booleans)
692+ - ** Enum values** for options and positionals with defined choices
693+ - ** Global options** at any command level
694+
695+ ``` shell
696+ $ my-cli < TAB>
697+ build test lint
698+
699+ $ my-cli build --target < TAB>
700+ dev staging prod
701+
702+ $ my-cli --< TAB>
703+ --verbose --config --help --version
704+ ```
705+
706+ See ` examples/completion.ts ` for a complete example.
707+
647708## Advanced Usage
648709
649710### Error Handling
You can’t perform that action at this time.
0 commit comments