View Source Shell.Completion (fnord v0.6.4)
Public API for generating shell completion scripts.
This module defines the DSL types and provides a single function to generate a completion script for a given shell type.
Example
Shell.Completion.generate(spec, shell: :bash)
Summary
Types
Specification for an argument.
Specification for a top-level command.
A source for completions: static choices, command output, files, directories, or a custom function (not supported).
Specification for an option.
Specification for a subcommand.
Functions
Generates a shell completion script for the given spec.
Types
@type argument_spec() :: %{name: String.t(), from: completion_source()}
Specification for an argument.
@type command_spec() :: %{ :name => String.t(), optional(:description) => String.t(), optional(:subcommands) => [subcommand_spec()], optional(:arguments) => [argument_spec()], optional(:options) => [option_spec()] }
Specification for a top-level command.
@type completion_source() :: {:choices, [String.t()]} | {:command, String.t()} | :files | :directories | (String.t() -> [String.t()])
A source for completions: static choices, command output, files, directories, or a custom function (not supported).
@type option_spec() :: %{ :name => String.t(), optional(:from) => completion_source(), optional(:takes_argument) => boolean() }
Specification for an option.
@type subcommand_spec() :: %{ :name => String.t(), optional(:description) => String.t(), optional(:arguments) => [argument_spec()], optional(:options) => [option_spec()], optional(:subcommands) => [subcommand_spec()] }
Specification for a subcommand.
Functions
@spec generate( command_spec(), keyword() ) :: String.t()
Generates a shell completion script for the given spec.
Options
:shell
- The type of shell to generate completions for (currently only:bash
and:zsh
are supported).
Example
Shell.Completion.generate(spec, shell: :bash)