Add shell completion templates and manpage template
This commit is contained in:
43
src/templates/completion-bash.handlebars
Normal file
43
src/templates/completion-bash.handlebars
Normal file
@@ -0,0 +1,43 @@
|
||||
# bash completion for {{spec.name}} v{{spec.version}} #
|
||||
# Auto-generated by cli-spec-generator
|
||||
|
||||
{{spec.name}}() {
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# Main commands
|
||||
if [[ $cword -eq 1 ]]; then
|
||||
COMPREPLY=( $( compgen -W '
|
||||
{{#each spec.commands}}
|
||||
{{name}}{{#if aliases}} {{aliases}}{{/if}}
|
||||
{{/each}}
|
||||
--help
|
||||
--version
|
||||
' -- "$cur" ) )
|
||||
return
|
||||
fi
|
||||
|
||||
# Command-specific options and arguments
|
||||
local cmd="${words[1]}"
|
||||
case "$cmd" in
|
||||
{{#each spec.commands}}
|
||||
{{name}})
|
||||
if [[ "$prev" == "--"* ]]; then
|
||||
COMPREPLY=( $( compgen -W '
|
||||
{{#each options}}
|
||||
--{{name}}{{#if short}} -{{short}}{{/if}}
|
||||
{{/each}}
|
||||
--help
|
||||
' -- "$cur" ) )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '
|
||||
{{#each options}}
|
||||
--{{name}}{{#if short}} -{{short}}{{/if}}
|
||||
{{/each}}
|
||||
--help
|
||||
' -- "$cur" ) )
|
||||
fi
|
||||
;;
|
||||
{{/each}}
|
||||
esac
|
||||
} && complete -F {{spec.name}} {{spec.name}}
|
||||
Reference in New Issue
Block a user