Update completions

This commit is contained in:
Vincent Prouillet 2018-02-02 17:37:30 +01:00
parent f7cacba3f0
commit f179d183ef
4 changed files with 39 additions and 17 deletions

View file

@ -1,39 +1,50 @@
#compdef gutenberg #compdef gutenberg
autoload -U is-at-least
_gutenberg() { _gutenberg() {
typeset -A opt_args typeset -A opt_args
typeset -a _arguments_options
local ret=1 local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line local context curcontext="$curcontext" state line
_arguments -s -S -C \ _arguments "${_arguments_options[@]}" \
'-c[Path to a config file other than config.toml]' \ '-c[Path to a config file other than config.toml]' \
'--config[Path to a config file other than config.toml]' \ '--config[Path to a config file other than config.toml]' \
'-h[Prints help information]' \ '-h[Prints help information]' \
'--help[Prints help information]' \ '--help[Prints help information]' \
'-V[Prints version information]' \ '-V[Prints version information]' \
'--version[Prints version information]' \ '--version[Prints version information]' \
"1:: :_gutenberg_commands" \ ":: :_gutenberg_commands" \
"*:: :->gutenberg" \ "*::: :->gutenberg" \
&& ret=0 && ret=0
case $state in case $state in
(gutenberg) (gutenberg)
curcontext="${curcontext%:*:*}:gutenberg-command-$words[1]:" words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:gutenberg-command-$line[1]:"
case $line[1] in case $line[1] in
(init) (init)
_arguments -s -S -C \ _arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \ '-h[Prints help information]' \
'--help[Prints help information]' \ '--help[Prints help information]' \
'-V[Prints version information]' \ '-V[Prints version information]' \
'--version[Prints version information]' \ '--version[Prints version information]' \
"1:: :_gutenberg__init_commands" \ ':name -- Name of the project. Will create a new directory with that name in the current directory:_files' \
&& ret=0 && ret=0
;; ;;
(build) (build)
_arguments -s -S -C \ _arguments "${_arguments_options[@]}" \
'-u+[Force the base URL to be that value (default to the one in config.toml)]' \ '-u+[Force the base URL to be that value (default to the one in config.toml)]' \
'--base-url+[Force the base URL to be that value (default to the one in config.toml)]' \ '--base-url=[Force the base URL to be that value (default to the one in config.toml)]' \
'-o+[Outputs the generated site in the given path]' \ '-o+[Outputs the generated site in the given path]' \
'--output-dir+[Outputs the generated site in the given path]' \ '--output-dir=[Outputs the generated site in the given path]' \
'-h[Prints help information]' \ '-h[Prints help information]' \
'--help[Prints help information]' \ '--help[Prints help information]' \
'-V[Prints version information]' \ '-V[Prints version information]' \
@ -41,13 +52,15 @@ _arguments -s -S -C \
&& ret=0 && ret=0
;; ;;
(serve) (serve)
_arguments -s -S -C \ _arguments "${_arguments_options[@]}" \
'-i+[Interface to bind on]' \ '-i+[Interface to bind on]' \
'--interface+[Interface to bind on]' \ '--interface=[Interface to bind on]' \
'-p+[Which port to use]' \ '-p+[Which port to use]' \
'--port+[Which port to use]' \ '--port=[Which port to use]' \
'-o+[Outputs the generated site in the given path]' \ '-o+[Outputs the generated site in the given path]' \
'--output-dir+[Outputs the generated site in the given path]' \ '--output-dir=[Outputs the generated site in the given path]' \
'-u+[Changes the base_url]' \
'--base-url=[Changes the base_url]' \
'-h[Prints help information]' \ '-h[Prints help information]' \
'--help[Prints help information]' \ '--help[Prints help information]' \
'-V[Prints version information]' \ '-V[Prints version information]' \
@ -55,7 +68,7 @@ _arguments -s -S -C \
&& ret=0 && ret=0
;; ;;
(help) (help)
_arguments -s -S -C \ _arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \ '-h[Prints help information]' \
'--help[Prints help information]' \ '--help[Prints help information]' \
'-V[Prints version information]' \ '-V[Prints version information]' \
@ -94,7 +107,7 @@ _gutenberg__help_commands() {
(( $+functions[_gutenberg__init_commands] )) || (( $+functions[_gutenberg__init_commands] )) ||
_gutenberg__init_commands() { _gutenberg__init_commands() {
local commands; commands=( local commands; commands=(
"NAME:Name of the project. Will create a new directory with that name in the current directory" \
) )
_describe -t commands 'gutenberg init commands' commands "$@" _describe -t commands 'gutenberg init commands' commands "$@"
} }

View file

@ -57,7 +57,7 @@
} }
'_gutenberg_serve' { '_gutenberg_serve' {
$completions = @('-h', '-V', '-i', '-p', '-o', '--help', '--version', '--interface', '--port', '--output-dir') $completions = @('-h', '-V', '-i', '-p', '-o', '-u', '--help', '--version', '--interface', '--port', '--output-dir', '--base-url')
} }
'_gutenberg_help' { '_gutenberg_help' {

View file

@ -109,7 +109,7 @@ _gutenberg() {
return 0 return 0
;; ;;
gutenberg__serve) gutenberg__serve)
opts=" -h -V -i -p -o --help --version --interface --port --output-dir " opts=" -h -V -i -p -o -u --help --version --interface --port --output-dir --base-url "
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0
@ -140,6 +140,14 @@ _gutenberg() {
COMPREPLY=("<output_dir>") COMPREPLY=("<output_dir>")
return 0 return 0
;; ;;
--base-url)
COMPREPLY=("<base_url>")
return 0
;;
-u)
COMPREPLY=("<base_url>")
return 0
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;

View file

@ -27,6 +27,7 @@ complete -c gutenberg -n "__fish_using_command gutenberg build" -s V -l version
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s i -l interface -d 'Interface to bind on' complete -c gutenberg -n "__fish_using_command gutenberg serve" -s i -l interface -d 'Interface to bind on'
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s p -l port -d 'Which port to use' complete -c gutenberg -n "__fish_using_command gutenberg serve" -s p -l port -d 'Which port to use'
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s o -l output-dir -d 'Outputs the generated site in the given path' complete -c gutenberg -n "__fish_using_command gutenberg serve" -s o -l output-dir -d 'Outputs the generated site in the given path'
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s u -l base-url -d 'Changes the base_url'
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s h -l help -d 'Prints help information' complete -c gutenberg -n "__fish_using_command gutenberg serve" -s h -l help -d 'Prints help information'
complete -c gutenberg -n "__fish_using_command gutenberg serve" -s V -l version -d 'Prints version information' complete -c gutenberg -n "__fish_using_command gutenberg serve" -s V -l version -d 'Prints version information'
complete -c gutenberg -n "__fish_using_command gutenberg help" -s h -l help -d 'Prints help information' complete -c gutenberg -n "__fish_using_command gutenberg help" -s h -l help -d 'Prints help information'