2020-01-15 01:20:38 -08:00
|
|
|
_just() {
|
2024-05-14 20:29:40 -07:00
|
|
|
local i cur prev words cword opts cmd
|
2020-01-15 01:20:38 -08:00
|
|
|
COMPREPLY=()
|
2024-01-27 14:02:38 -08:00
|
|
|
|
|
|
|
# Modules use "::" as the separator, which is considered a wordbreak character in bash.
|
|
|
|
# The _get_comp_words_by_ref function is a hack to allow for exceptions to this rule without
|
|
|
|
# modifying the global COMP_WORDBREAKS environment variable.
|
|
|
|
if type _get_comp_words_by_ref &>/dev/null; then
|
|
|
|
_get_comp_words_by_ref -n : cur prev words cword
|
|
|
|
else
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
words=$COMP_WORDS
|
|
|
|
cword=$COMP_CWORD
|
|
|
|
fi
|
|
|
|
|
2020-01-15 01:20:38 -08:00
|
|
|
cmd=""
|
|
|
|
opts=""
|
|
|
|
|
2024-01-27 14:02:38 -08:00
|
|
|
for i in ${words[@]}
|
2020-01-15 01:20:38 -08:00
|
|
|
do
|
2024-05-14 20:29:40 -07:00
|
|
|
case "${cmd},${i}" in
|
|
|
|
",$1")
|
2020-01-15 01:20:38 -08:00
|
|
|
cmd="just"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
case "${cmd}" in
|
2024-05-14 20:29:40 -07:00
|
|
|
"$1")
|
|
|
|
opts="-n -f -q -u -v -d -c -e -l -s -E -h -V --check --chooser --color --command-color --yes --dry-run --dump-format --highlight --list-heading --list-prefix --no-aliases --no-deps --no-dotenv --no-highlight --justfile --quiet --set --shell --shell-arg --shell-command --clear-shell-args --unsorted --unstable --verbose --working-directory --changelog --choose --command --completions --dump --edit --evaluate --fmt --init --list --show --summary --variables --dotenv-filename --dotenv-path --help --version [ARGUMENTS]..."
|
2020-10-05 17:58:30 -07:00
|
|
|
if [[ ${cur} == -* ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
2024-01-27 14:02:38 -08:00
|
|
|
elif [[ ${cword} -eq 1 ]]; then
|
2022-09-23 20:34:55 -07:00
|
|
|
local recipes=$(just --summary 2> /dev/null)
|
|
|
|
|
2023-06-17 17:05:49 -07:00
|
|
|
if echo "${cur}" | \grep -qF '/'; then
|
2022-09-23 20:34:55 -07:00
|
|
|
local path_prefix=$(echo "${cur}" | sed 's/[/][^/]*$/\//')
|
|
|
|
local recipes=$(just --summary 2> /dev/null -- "${path_prefix}")
|
|
|
|
local recipes=$(printf "${path_prefix}%s\t" $recipes)
|
|
|
|
fi
|
|
|
|
|
2020-10-05 17:58:30 -07:00
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
COMPREPLY=( $(compgen -W "${recipes}" -- "${cur}") )
|
2024-01-27 14:02:38 -08:00
|
|
|
if type __ltrim_colon_completions &>/dev/null; then
|
|
|
|
__ltrim_colon_completions "$cur"
|
|
|
|
fi
|
2020-10-05 17:58:30 -07:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
2020-01-15 01:20:38 -08:00
|
|
|
case "${prev}" in
|
2020-09-17 19:43:04 -07:00
|
|
|
--chooser)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2020-01-15 01:20:38 -08:00
|
|
|
--color)
|
|
|
|
COMPREPLY=($(compgen -W "auto always never" -- "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2023-10-10 17:04:34 -07:00
|
|
|
--command-color)
|
|
|
|
COMPREPLY=($(compgen -W "black blue cyan green purple red yellow" -- "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2021-11-17 00:07:48 -08:00
|
|
|
--dump-format)
|
|
|
|
COMPREPLY=($(compgen -W "just json" -- "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2021-02-09 01:00:04 -08:00
|
|
|
--list-heading)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--list-prefix)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2020-01-15 01:20:38 -08:00
|
|
|
--justfile)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2024-05-14 20:29:40 -07:00
|
|
|
-f)
|
2020-01-15 01:20:38 -08:00
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--set)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--shell)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--shell-arg)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--working-directory)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2024-05-14 20:29:40 -07:00
|
|
|
-d)
|
2020-01-15 01:20:38 -08:00
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2021-05-09 20:35:35 -07:00
|
|
|
--command)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2024-05-14 20:29:40 -07:00
|
|
|
-c)
|
2021-05-09 20:35:35 -07:00
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2020-01-15 01:20:38 -08:00
|
|
|
--completions)
|
2024-05-14 20:29:40 -07:00
|
|
|
COMPREPLY=($(compgen -W "bash elvish fish powershell zsh" -- "${cur}"))
|
2020-01-15 01:20:38 -08:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--show)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2024-05-14 20:29:40 -07:00
|
|
|
-s)
|
2020-01-15 01:20:38 -08:00
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2021-08-08 22:37:35 -07:00
|
|
|
--dotenv-filename)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--dotenv-path)
|
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2024-05-14 20:29:40 -07:00
|
|
|
-E)
|
2024-03-19 10:50:34 -07:00
|
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
|
|
return 0
|
|
|
|
;;
|
2020-01-15 01:20:38 -08:00
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2024-05-14 20:29:40 -07:00
|
|
|
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
|
|
|
|
complete -F _just -o nosort -o bashdefault -o default just
|
|
|
|
else
|
|
|
|
complete -F _just -o bashdefault -o default just
|
|
|
|
fi
|