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
autoload -U is-at-least
_gutenberg() {
typeset -A opt_args
typeset -a _arguments_options
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
_arguments -s -S -C \
_arguments "${_arguments_options[@]}" \
'-c[Path to a config file other than config.toml]' \
'--config[Path to a config file other than config.toml]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
"1:: :_gutenberg_commands" \
"*:: :->gutenberg" \
":: :_gutenberg_commands" \
"*::: :->gutenberg" \
&& ret=0
case $state in
(gutenberg)
curcontext="${curcontext%:*:*}:gutenberg-command-$words[1]:"
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:gutenberg-command-$line[1]:"
case $line[1] in
(init)
_arguments -s -S -C \
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[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
;;
(build)
_arguments -s -S -C \
_arguments "${_arguments_options[@]}" \
'-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]' \
'--output-dir+[Outputs the generated site in the given path]' \
'--output-dir=[Outputs the generated site in the given path]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
@ -41,13 +52,15 @@ _arguments -s -S -C \
&& ret=0
;;
(serve)
_arguments -s -S -C \
_arguments "${_arguments_options[@]}" \
'-i+[Interface to bind on]' \
'--interface+[Interface to bind on]' \
'--interface=[Interface to bind on]' \
'-p+[Which port to use]' \
'--port+[Which port to use]' \
'--port=[Which port to use]' \
'-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]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
@ -55,7 +68,7 @@ _arguments -s -S -C \
&& ret=0
;;
(help)
_arguments -s -S -C \
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
@ -94,7 +107,7 @@ _gutenberg__help_commands() {
(( $+functions[_gutenberg__init_commands] )) ||
_gutenberg__init_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 "$@"
}

View file

@ -57,7 +57,7 @@
}
'_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' {

View file

@ -109,7 +109,7 @@ _gutenberg() {
return 0
;;
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
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@ -140,6 +140,14 @@ _gutenberg() {
COMPREPLY=("<output_dir>")
return 0
;;
--base-url)
COMPREPLY=("<base_url>")
return 0
;;
-u)
COMPREPLY=("<base_url>")
return 0
;;
*)
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 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 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 V -l version -d 'Prints version information'
complete -c gutenberg -n "__fish_using_command gutenberg help" -s h -l help -d 'Prints help information'