2020-01-15 01:20:38 -08:00
#compdef just
autoload -U is-at-least
_just( ) {
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
2020-03-16 17:20:14 -07:00
local common = (
2020-09-17 19:43:04 -07:00
'--chooser=[Override binary invoked by `--choose`]' \
2020-01-15 01:20:38 -08:00
'--color=[Print colorful output]: :(auto always never)' \
'-f+[Use <JUSTFILE> as justfile.]' \
'--justfile=[Use <JUSTFILE> as justfile.]' \
2020-03-16 17:20:14 -07:00
'*--set[Override <VARIABLE> with <VALUE>]: :_just_variables' \
2020-01-15 01:20:38 -08:00
'--shell=[Invoke <SHELL> to run recipes]' \
'*--shell-arg=[Invoke shell with <SHELL-ARG> as an argument]' \
'-d+[Use <WORKING-DIRECTORY> as working directory. --justfile must also be set]' \
'--working-directory=[Use <WORKING-DIRECTORY> as working directory. --justfile must also be set]' \
'--completions=[Print shell completion script for <SHELL>]: :(zsh bash fish powershell elvish)' \
2020-03-16 17:20:14 -07:00
'-s+[Show information about <RECIPE>]: :_just_commands' \
'--show=[Show information about <RECIPE>]: :_just_commands' \
2020-01-15 01:20:38 -08:00
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
'--highlight[Highlight echoed recipe lines in bold]' \
2020-05-23 20:41:12 -07:00
'--no-dotenv[Don' \' 't load `.env` file]' \
2020-01-15 01:20:38 -08:00
'--no-highlight[Don' \' 't highlight echoed recipe lines in bold]' \
'(--dry-run)-q[Suppress all output]' \
'(--dry-run)--quiet[Suppress all output]' \
'--clear-shell-args[Clear shell arguments]' \
2020-08-21 15:13:54 -07:00
'-u[Return list and summary entries in source order]' \
'--unsorted[Return list and summary entries in source order]' \
2020-01-15 01:20:38 -08:00
'*-v[Use verbose output]' \
'*--verbose[Use verbose output]' \
2020-09-17 19:43:04 -07:00
'--choose[Select a recipe to run using a binary. If `--chooser` is not passed the chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf`]' \
2020-01-15 01:20:38 -08:00
'--dump[Print entire justfile]' \
'-e[Edit justfile with editor given by $VISUAL or $EDITOR, falling back to `vim`]' \
'--edit[Edit justfile with editor given by $VISUAL or $EDITOR, falling back to `vim`]' \
'--evaluate[Print evaluated variables]' \
'--init[Initialize new justfile in project root]' \
'-l[List available recipes and their arguments]' \
'--list[List available recipes and their arguments]' \
'--summary[List names of available recipes]' \
2020-03-13 22:19:43 -07:00
'--variables[List names of variables]' \
2020-01-15 01:20:38 -08:00
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
2020-03-16 17:20:14 -07:00
)
_arguments " ${ _arguments_options [@] } " $common \
'1: :_just_commands' \
'*: :->args' \
&& ret = 0
case $state in
args)
curcontext = " ${ curcontext % : * } - ${ words [2] } : "
local lastarg = ${ words [ ${# words } ] }
if [ [ ${ lastarg } = */* ] ] ; then
# Arguments contain slash would be recognised as a file
_arguments -s -S $common '*:: :_files'
else
# Show usage message
_message " `just --show ${ words [2] } ` "
# Or complete with other commands
#_arguments -s -S $common '*:: :_just_commands'
fi
; ;
esac
return ret
2020-01-15 01:20:38 -08:00
}
( ( $+functions[ _just_commands] ) ) ||
_just_commands( ) {
local commands; commands = (
2020-03-16 17:20:14 -07:00
${ ${ ${ (M) " ${ (f) $( _call_program commands just --list) } " : # * } / ##/ } / ##/ : Args : }
2020-01-15 01:20:38 -08:00
)
2020-03-16 17:20:14 -07:00
2020-01-15 01:20:38 -08:00
_describe -t commands 'just commands' commands " $@ "
}
2020-03-16 17:20:14 -07:00
( ( $+functions[ _just_variables] ) ) ||
_just_variables( ) {
local variables; variables = (
${ (s : : ) $( _call_program commands just --variables) }
)
_describe -t variables 'variables' variables
}
2020-03-14 21:41:57 -07:00
_just " $@ "