silk.cli.completion.

Shell completion scripts for a command, written during compilation from its description.

When to use#

Give your program a way to print the script, such as a --completions bash option, and tell users to load it: source <(mytool --completions bash) in ~/.bashrc, the same with zsh in ~/.zshrc, or mytool --completions fish | source in ~/.config/fish/config.fish.

Details#

The script completes subcommand names, option names and aliases, and the choices of an option or positional argument (see Opt.choice). It follows the subcommands already typed, so git remote <Tab> offers the options and subcommands of remote. Where a command takes positional arguments without choices, the script completes file names too. The zsh script loads zsh's completion system and its bash support if needed, and uses the bash script.

Import as Completion with import silk.cli.completion { Completion }.

Public declarations: 1.

Completion#

silk
pub struct Completion

The owner type of the completion writers. It has no fields and is never constructed.

Implementation Completion#

silk
impl Completion

Associated function writeBash#

silk
pub effect fn writeBash<T: CommandLine>() -> ()
    ! WriterError
    ? &mut Writer

Writes a bash completion script for the command that T describes.

Errors#

  • WriterError if the Writer fails.

Associated function writeZsh#

silk
pub effect fn writeZsh<T: CommandLine>() -> ()
    ! WriterError
    ? &mut Writer

Writes a zsh completion script for the command that T describes.

Errors#

  • WriterError if the Writer fails.

Associated function writeFish#

silk
pub effect fn writeFish<T: CommandLine>() -> ()
    ! WriterError
    ? &mut Writer

Writes a fish completion script for the command that T describes.

Errors#

  • WriterError if the Writer fails.

Category: Command line.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page