mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
118 lines
3.5 KiB
Bash
118 lines
3.5 KiB
Bash
_my-app() {
|
|
local i cur prev opts cmd
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
cmd=""
|
|
opts=""
|
|
|
|
for i in ${COMP_WORDS[@]}
|
|
do
|
|
case "${cmd},${i}" in
|
|
",$1")
|
|
cmd="my__app"
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case "${cmd}" in
|
|
my__app)
|
|
opts="-p -f -d -e -c -u -H -h --choice --unknown --other --path --file --dir --exe --cmd-name --cmd --user --host --url --email --help [command_with_args]..."
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
return 0
|
|
fi
|
|
case "${prev}" in
|
|
--choice)
|
|
COMPREPLY=($(compgen -W "bash fish zsh" -- "${cur}"))
|
|
return 0
|
|
;;
|
|
--unknown)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--other)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--path)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-p)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--file)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-f)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--dir)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-d)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--exe)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-e)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--cmd-name)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--cmd)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-c)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--user)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-u)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--host)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
-H)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--url)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
--email)
|
|
COMPREPLY=($(compgen -f "${cur}"))
|
|
return 0
|
|
;;
|
|
*)
|
|
COMPREPLY=()
|
|
;;
|
|
esac
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
return 0
|
|
;;
|
|
esac
|
|
}
|
|
|
|
complete -F _my-app -o bashdefault -o default my-app
|