Add shell completion templates and manpage template
This commit is contained in:
39
src/templates/completion-zsh.handlebars
Normal file
39
src/templates/completion-zsh.handlebars
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#compdef _{{spec.name}} {{spec.name}}
|
||||||
|
# Zsh completion for {{spec.name}}
|
||||||
|
# Auto-generated by cli-spec-generator
|
||||||
|
|
||||||
|
_{{_name}}() {
|
||||||
|
local line
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
'(-h --help)'{-h,--help}'[Show help]' \
|
||||||
|
'(-v --version)'{-v,--version}'[Show version]' \
|
||||||
|
{{#each spec.globalOptions}}
|
||||||
|
'{{#if short}}-{{short}}, {{/if}}--{{name}}[{{escape description}}]' \
|
||||||
|
{{/each}}
|
||||||
|
{{#each spec.commands}}
|
||||||
|
'{{name}}[{{escape description}}]' \
|
||||||
|
{{/each}}
|
||||||
|
'*::arg:->args'
|
||||||
|
|
||||||
|
if [[ -z "$line" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local cmd="${line[1]}"
|
||||||
|
shift line
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
{{#each spec.commands}}
|
||||||
|
{{name}})
|
||||||
|
_arguments \
|
||||||
|
{{#each options}}
|
||||||
|
'{{#if short}}-{{short}}, {{/if}}--{{name}}[{{escape description}}]' \
|
||||||
|
{{/each}}
|
||||||
|
'*::arg:->args'
|
||||||
|
;;
|
||||||
|
{{/each}}
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_{{_spec.name}} "$@"
|
||||||
Reference in New Issue
Block a user