carapace
carapace copied to clipboard
command argument completion generator for spf13/cobra
carapace
Command argument completion generator for cobra. You can read more about it here: A pragmatic approach to shell completion.
Supported shells:
- Bash
- Elvish
- Fish
- Ion (experimental)
- Nushell (experimental)
- Oil
- Powershell
- Tcsh (experimental)
- Xonsh
- Zsh
Usage
Calling carapace.Gen
on the root command is sufficient to enable completion script generation using the hidden command.
import (
"github.com/rsteube/carapace"
)
carapace.Gen(rootCmd)
Standalone Mode
Carapace can also be used to provide completion for arbitrary commands as well (similar to aws_completer). See rsteube/carapace-bin for examples. There is also a binary to parse flags from gnu help pages at caraparse.
Example
An example implementation can be found in the example folder.
cd example
go build .
# bash
PATH=$PATH:$(pwd)
source <(example _carapace bash)
# elvish
paths=[$@paths (pwd)]
eval (example _carapace elvish | slurp)
# fish
set PATH $PATH (pwd)
example _carapace fish | source
# nushell
example _carapace nushell
# oil
PATH=$PATH:$(pwd)
source <(example _carapace oil)
# powershell
Set-PSReadLineOption -Colors @{ "Selection" = "`e[7m" }
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
$env:PATH += ":$pwd"
example _carapace powershell | out-string | Invoke-Expression
# tcsh
set autolist
eval `example _carapace tcsh`
# xonsh
$COMPLETION_QUERY_LIMIT = 500 # increase limit
$PATH.append($(pwd))
exec($(example _carapace xonsh))
# zsh
PATH=$PATH:$(pwd)
source <(example _carapace zsh)
example <TAB>
or use docker-compose:
docker-compose pull
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|ion|nushell|oil|powershell|tcsh|xonsh|zsh]
example <TAB>
Projects
- carapace-bin multi-shell multi-command argument completer
- carapace-spec define simple completions using a spec file
- freckles simple dotfiles manager
- go-jira-cli simple jira command line client
- knoxite A data storage & backup system
- lab cli client for GitLab