Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add bash completion #352

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions install/shell-completion/dae.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# bash completion for dae -*- shell-script -*-
#
# To be installed in "/usr/share/bash-completion/completions/dae"

_dae() {
local prev cur cmd export_cmd run_opts validate_opts
COMPREPLY=()

prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
cmd="export help honk reload run suspend validate"
export_cmd="outline"
run_opts="-c --config --disable-pidfile --disable-timestamp --logfile \
--logfile-maxbackups --logfile-maxsize"
validate_opts="-c --config"

case "${prev}" in
help)
return 0
;;

honk|reload|suspend|outline)
COMPREPLY=( $(compgen -W "-h --help" -- "${cur}") )
return 0
;;

export)
COMPREPLY=( $(compgen -W "$export_cmd -h --help" -- "${cur}") )
return 0
;;

run)
COMPREPLY=( $(compgen -W "$run_opts -h --help" -- \
"${cur}") )
return 0
;;

validate)
COMPREPLY=( $(compgen -W "$validate_opts -h --help" -- \
"${cur}") )
return 0
;;

# multiple option matching
--disable-pidfile|--disable-timestamp|--logfile|--logfile-maxbackup|\
--logfile-maxsize|-c|--config|*/*)

case "${prev}" in
--logfile)
_filedir
return 0
;;
esac

case "${prev}" in
-c|--config)
_filedir -d
return 0
;;
esac

case "${COMP_WORDS[1]}" in
run)
COMPREPLY=( $(compgen -W "$run_opts" -- "${cur}") )
return 0
;;
esac

return 0
;;

-h|--help)
return 0
;;
*)
;;
esac

case "${cur}" in
-*)
COMPREPLY=( $( compgen -W "--version --help -v -h" -- "${cur}") )
return 0
;;
--*)
COMPREPLY=( $( compgen -W "--version --help" -- "${cur}") )
return 0
;;
*)
case "${COMP_WORDS[1]}" in
export|help|honk|reload|run|suspend|validate)
return 0
;;
esac
COMPREPLY=( $( compgen -W "${cmd}" -- "${cur}") )
return 0
;;

esac

}

complete -F _dae dae