Update completions

This commit is contained in:
Vincent Prouillet 2017-10-20 10:44:14 +02:00
parent 5318c9bc4c
commit 8a76df0af3
4 changed files with 82 additions and 59 deletions

View file

@ -6,51 +6,56 @@ _gutenberg() {
local context curcontext="$curcontext" state line local context curcontext="$curcontext" state line
_arguments -s -S -C \ _arguments -s -S -C \
"-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" \ "1:: :_gutenberg_commands" \
"*:: :->Gutenberg" \ "*:: :->gutenberg" \
&& ret=0 && ret=0
case $state in case $state in
(Gutenberg) (gutenberg)
curcontext="${curcontext%:*:*}:gutenberg-command-$words[1]:" curcontext="${curcontext%:*:*}:gutenberg-command-$words[1]:"
case $line[1] in case $line[1] in
(init) (init)
_arguments -s -S -C \ _arguments -s -S -C \
"-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" \ "1:: :_gutenberg__init_commands" \
&& ret=0 && ret=0
;; ;;
(build) (build)
_arguments -s -S -C \ _arguments -s -S -C \
"-h[Prints help information]" \ '-u+[Force the base URL to be that value (default to the one in config.toml)]' \
"--help[Prints help information]" \ '--base-url+[Force the base URL to be that value (default to the one in config.toml)]' \
"-V[Prints version information]" \ '-h[Prints help information]' \
"--version[Prints version information]" \ '--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0 && ret=0
;; ;;
(serve) (serve)
_arguments -s -S -C \ _arguments -s -S -C \
"-h[Prints help information]" \ '-i+[Interface to bind on]' \
"--help[Prints help information]" \ '--interface+[Interface to bind on]' \
"-V[Prints version information]" \ '-p+[Which port to use]' \
"--version[Prints version information]" \ '--port+[Which port to use]' \
"1:: :_gutenberg__serve_commands" \ '-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0 && ret=0
;; ;;
(help) (help)
_arguments -s -S -C \ _arguments -s -S -C \
"-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]' \
&& ret=0 && ret=0
;; ;;
esac esac
@ -85,15 +90,14 @@ _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 directory with that name in the current directory" \ "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 "$@"
} }
(( $+functions[_gutenberg__serve_commands] )) || (( $+functions[_gutenberg__serve_commands] )) ||
_gutenberg__serve_commands() { _gutenberg__serve_commands() {
local commands; commands=( local commands; commands=(
"INTERFACE:Interface to bind on (default to 127.0.0.1)" \
"PORT:Which port to use (default to 1111)" \
) )
_describe -t commands 'gutenberg serve commands' commands "$@" _describe -t commands 'gutenberg serve commands' commands "$@"
} }

View file

@ -9,8 +9,8 @@
%{ %{
switch ($_.ToString()) { switch ($_.ToString()) {
'Gutenberg' { 'gutenberg' {
$command += '_Gutenberg' $command += '_gutenberg'
break break
} }
@ -45,7 +45,7 @@
switch ($command) { switch ($command) {
'_gutenberg' { '_gutenberg' {
$completions = @('init', 'build', 'serve', 'help', '-h', '-V', '-c', '--help', '--version', '--config') $completions = @('init', 'build', 'serve', 'help', '-c', '-h', '-V', '--config', '--help', '--version')
} }
'_gutenberg_init' { '_gutenberg_init' {
@ -53,11 +53,11 @@
} }
'_gutenberg_build' { '_gutenberg_build' {
$completions = @('-h', '-V', '--help', '--version') $completions = @('-h', '-V', '-u', '--help', '--version', '--base-url')
} }
'_gutenberg_serve' { '_gutenberg_serve' {
$completions = @('-h', '-V', '--help', '--version') $completions = @('-h', '-V', '-i', '-p', '--help', '--version', '--interface', '--port')
} }
'_gutenberg_help' { '_gutenberg_help' {

View file

@ -32,21 +32,13 @@ _gutenberg() {
case "${cmd}" in case "${cmd}" in
gutenberg) gutenberg)
opts=" -h -V -c --help --version --config init build serve help" opts=" -c -h -V --config --help --version init build serve help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0
fi fi
case "${prev}" in case "${prev}" in
--config)
COMPREPLY=("<config>")
return 0
;;
-c)
COMPREPLY=("<config>")
return 0
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
@ -56,13 +48,21 @@ _gutenberg() {
;; ;;
gutenberg__build) gutenberg__build)
opts=" -h -V --help --version " opts=" -h -V -u --help --version --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
fi fi
case "${prev}" in case "${prev}" in
--base-url)
COMPREPLY=("<base_url>")
return 0
;;
-u)
COMPREPLY=("<base_url>")
return 0
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;
@ -101,13 +101,29 @@ _gutenberg() {
return 0 return 0
;; ;;
gutenberg__serve) gutenberg__serve)
opts=" -h -V --help --version <interface> <port> " opts=" -h -V -i -p --help --version --interface --port "
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
fi fi
case "${prev}" in case "${prev}" in
--interface)
COMPREPLY=("<interface>")
return 0
;;
-i)
COMPREPLY=("<interface>")
return 0
;;
--port)
COMPREPLY=("<port>")
return 0
;;
-p)
COMPREPLY=("<port>")
return 0
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;

View file

@ -11,18 +11,21 @@ function __fish_using_command
return 1 return 1
end end
complete -c gutenberg -n "__fish_using_command gutenberg" -s c -l config -d "Path to a config file other than config.toml" complete -c gutenberg -n "__fish_using_command gutenberg" -s c -l config -d 'Path to a config file other than config.toml'
complete -c gutenberg -n "__fish_using_command gutenberg" -s h -l help -d "Prints help information" complete -c gutenberg -n "__fish_using_command gutenberg" -s h -l help -d 'Prints help information'
complete -c gutenberg -n "__fish_using_command gutenberg" -s V -l version -d "Prints version information" complete -c gutenberg -n "__fish_using_command gutenberg" -s V -l version -d 'Prints version information'
complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "init" -d "Create a new Gutenberg project" complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "init" -d 'Create a new Gutenberg project'
complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "build" -d "Builds the site" complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "build" -d 'Builds the site'
complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "serve" -d "Serve the site. Rebuild and reload on change automatically" complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "serve" -d 'Serve the site. Rebuild and reload on change automatically'
complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "help" -d "Prints this message or the help of the given subcommand(s)" complete -c gutenberg -n "__fish_using_command gutenberg" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)'
complete -c gutenberg -n "__fish_using_command gutenberg init" -s h -l help -d "Prints help information" complete -c gutenberg -n "__fish_using_command gutenberg init" -s h -l help -d 'Prints help information'
complete -c gutenberg -n "__fish_using_command gutenberg init" -s V -l version -d "Prints version information" complete -c gutenberg -n "__fish_using_command gutenberg init" -s V -l version -d 'Prints version information'
complete -c gutenberg -n "__fish_using_command gutenberg build" -s h -l help -d "Prints help information" complete -c gutenberg -n "__fish_using_command gutenberg build" -s u -l base-url -d 'Force the base URL to be that value (default to the one in config.toml)'
complete -c gutenberg -n "__fish_using_command gutenberg build" -s V -l version -d "Prints version information" complete -c gutenberg -n "__fish_using_command gutenberg build" -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 build" -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 serve" -s i -l interface -d 'Interface to bind on'
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 serve" -s p -l port -d 'Which port to use'
complete -c gutenberg -n "__fish_using_command gutenberg help" -s V -l version -d "Prints version 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 help" -s h -l help -d 'Prints help information'
complete -c gutenberg -n "__fish_using_command gutenberg help" -s V -l version -d 'Prints version information'