pub fn render_completion(
shell: Shell,
program: &str,
registry: &Registry,
) -> StringExpand description
Generate a shell completion script for a registry of commands.
The generated script hooks into the shell’s native completion mechanism. Source it in your shell profile to enable tab-completion for your tool.
§Arguments
shell— the target shellprogram— the program name as it appears inPATH(e.g."mytool")registry— thecrate::query::Registrycontaining all commands
§Examples
let registry = Registry::new(vec![
Command::builder("deploy")
.flag(Flag::builder("env").takes_value().choices(["prod", "staging"]).build().unwrap())
.build().unwrap(),
Command::builder("status").build().unwrap(),
]);
let script = render_completion(Shell::Bash, "mytool", ®istry);
assert!(script.contains("mytool"));
assert!(script.contains("deploy"));
assert!(script.contains("status"));