Args module

completions

procedureextensionSource

The completion script for shell, to be saved where that shell loads completions from. The program name is argv[0]'s basename unless program says otherwise.

Example↗
Args :: #import "Extensions/Args";

Cli :: struct { verbose: bool; @short=v }
HELP :: Args.Help(Cli).{ verbose = "Talk more" };

script := Args.completions(Cli, HELP, .BASH, "tool");
assert(script.count > 0);
completions :: ($T: Type, $help: Help(T), shell: Shell, program := "") -> string

The completion script for shell, to be saved where that shell loads completions from. The program name is argv[0]'s basename unless program says otherwise.

Parameters

$T: Type
the struct whose fields are the options.
$help: Help(T)
the help strings for T.
shell: Shell
the shell to write the script for.
program := ""
the command name to complete; "" uses argv[0]'s basename.

Returns

string
Example↗
Args :: #import "Extensions/Args";

Cli :: struct { verbose: bool; @short=v }
HELP :: Args.Help(Cli).{ verbose = "Talk more" };

script := Args.completions(Cli, HELP, .BASH, "tool");
assert(script.count > 0);

See also