2022-03-07 20:03:46 +00:00
|
|
|
_my-app() {
|
|
|
|
local i cur prev opts cmds
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
cmd=""
|
|
|
|
opts=""
|
|
|
|
|
|
|
|
for i in ${COMP_WORDS[@]}
|
|
|
|
do
|
2022-09-28 14:33:31 +00:00
|
|
|
case "${cmd},${i}" in
|
|
|
|
",$1")
|
2022-03-07 20:03:46 +00:00
|
|
|
cmd="my__app"
|
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-backslash)
|
|
|
|
cmd="my__app__cmd__backslash"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-backticks)
|
|
|
|
cmd="my__app__cmd__backticks"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-brackets)
|
|
|
|
cmd="my__app__cmd__brackets"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-double-quotes)
|
|
|
|
cmd="my__app__cmd__double__quotes"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-expansions)
|
|
|
|
cmd="my__app__cmd__expansions"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,cmd-single-quotes)
|
|
|
|
cmd="my__app__cmd__single__quotes"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
2022-09-28 21:33:59 +00:00
|
|
|
my__app,help)
|
|
|
|
cmd="my__app__help"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-backslash)
|
|
|
|
cmd="my__app__help__cmd__backslash"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-backticks)
|
|
|
|
cmd="my__app__help__cmd__backticks"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-brackets)
|
|
|
|
cmd="my__app__help__cmd__brackets"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-double-quotes)
|
|
|
|
cmd="my__app__help__cmd__double__quotes"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-expansions)
|
|
|
|
cmd="my__app__help__cmd__expansions"
|
|
|
|
;;
|
|
|
|
my__app__help,cmd-single-quotes)
|
|
|
|
cmd="my__app__help__cmd__single__quotes"
|
|
|
|
;;
|
|
|
|
my__app__help,help)
|
|
|
|
cmd="my__app__help__help"
|
2022-03-07 20:03:46 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
case "${cmd}" in
|
|
|
|
my__app)
|
2022-08-08 21:08:47 +00:00
|
|
|
opts="-h -V --single-quotes --double-quotes --backticks --backslash --brackets --expansions --help --version cmd-single-quotes cmd-double-quotes cmd-backticks cmd-backslash cmd-brackets cmd-expansions help"
|
2022-03-07 20:03:46 +00:00
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__backslash)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__backticks)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__brackets)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__double__quotes)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__expansions)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__cmd__single__quotes)
|
|
|
|
opts="-h --help"
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help)
|
2022-08-25 05:44:07 +00:00
|
|
|
opts="cmd-single-quotes cmd-double-quotes cmd-backticks cmd-backslash cmd-brackets cmd-expansions help"
|
2022-03-07 20:03:46 +00:00
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
2022-08-25 05:44:07 +00:00
|
|
|
my__app__help__cmd__backslash)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__cmd__backticks)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__cmd__brackets)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__cmd__double__quotes)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__cmd__expansions)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__cmd__single__quotes)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
my__app__help__help)
|
|
|
|
opts=""
|
|
|
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
case "${prev}" in
|
|
|
|
*)
|
|
|
|
COMPREPLY=()
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
|
|
|
return 0
|
|
|
|
;;
|
2022-03-07 20:03:46 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _my-app -o bashdefault -o default my-app
|