apigenie completion

Since 0.13.0, apigenie completion prints the script that completes the commands, options and option values of apigenie in bash, zsh, fish or PowerShell. The script is written from the commands that apigenie commands lists, so it completes what the version that printed it accepts. apigenie-generator completion and apigenie-catalog completion print the scripts of those binaries.

Usage

apigenie completion SHELL

SHELL is bash, zsh, fish or powershell. The script goes to the standard output; load it from the shell’s startup file:

Shell Startup file Line
bash ~/.bashrc eval "$(apigenie completion bash)"
zsh ~/.zshrc, after compinit source <(apigenie completion zsh)
fish ~/.config/fish/config.fish apigenie completion fish | source
PowerShell $PROFILE apigenie completion powershell | Out-String | Invoke-Expression

The eval line works in every bash, the 3.2 of macOS included. For apigenie-generator and apigenie-catalog, use the same lines with their names.

A saved script loads without starting apigenie at every shell start; save it again after an upgrade. zsh loads _apigenie from a directory of $fpath; add fpath=(~/.zsh/completions $fpath) to ~/.zshrc before compinit. fish loads ~/.config/fish/completions/apigenie.fish:

mkdir -p ~/.zsh/completions ~/.config/fish/completions
apigenie completion zsh > ~/.zsh/completions/_apigenie
apigenie completion fish > ~/.config/fish/completions/apigenie.fish

What it completes

  • The commands and subcommands: apigenie i<Tab> offers i18n and init.
  • The options of the command typed so far, after a -: apigenie lint --f<Tab> offers --fix and --formatter. zsh, fish and PowerShell show what each option does.
  • The values of an option that accepts only some, such as the formats of apigenie diff --formatter, and of a positional argument that does, such as the shell of apigenie completion.
  • File names for the other values and for positional arguments, as the shell completes them.

Options

completion has no options besides -h/--help and --json. With --json, the script is the output of the status document.

Exit status

0 when the script is printed. 2 when SHELL is missing or is not one of the four, or on an unknown option.

See also

  • commands: Every command with its arguments and options, as a list or as JSON.
Last updated on View as Markdown
Was this helpful?