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#
pub struct CompletionThe owner type of the completion writers. It has no fields and is never constructed.
Implementation Completion#
impl CompletionAssociated function writeBash#
pub effect fn writeBash<T: CommandLine>() -> ()
! WriterError
? &mut WriterWrites a bash completion script for the command that T describes.
Errors#
WriterErrorif theWriterfails.
Associated function writeZsh#
pub effect fn writeZsh<T: CommandLine>() -> ()
! WriterError
? &mut WriterWrites a zsh completion script for the command that T describes.
Errors#
WriterErrorif theWriterfails.
Associated function writeFish#
pub effect fn writeFish<T: CommandLine>() -> ()
! WriterError
? &mut WriterWrites a fish completion script for the command that T describes.
Errors#
WriterErrorif theWriterfails.
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.