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 #376

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

_daed() {
local prev cur cmd export_cmd resetpwd_opts run_opts
COMPREPLY=()

prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
cmd="export help resetpass run"
export_cmd="flatdesc outline schema"
resetpwd_opts="-c --config"
run_opts="--api-only -c --config --disable-timestamp -l --listen --logfile\
--logfile-maxbackups --logfile-maxsize"

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

flatdesc|outline|schema)
COMPREPLY=( $(compgen -W "-h --help" -- "${cur}") )
return 0
;;

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

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

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

--api-only|--disable-timestamp|-l|--listen|--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

# run cmd multi option completetion
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|resetpass|run)
return 0
;;
esac
COMPREPLY=( $( compgen -W "${cmd}" -- "${cur}") )
return 0
;;

esac

}

complete -F _daed daed