aboutsummaryrefslogtreecommitdiff
path: root/bash-completion/accerso
diff options
context:
space:
mode:
Diffstat (limited to 'bash-completion/accerso')
-rw-r--r--bash-completion/accerso73
1 files changed, 73 insertions, 0 deletions
diff --git a/bash-completion/accerso b/bash-completion/accerso
new file mode 100644
index 000000000..d77a3ff20
--- /dev/null
+++ b/bash-completion/accerso
@@ -0,0 +1,73 @@
+# Bash completion function for accerso
+# vim: set et sw=4 sts=4 ts=4 ft=sh :
+
+# NOTE: This is still a work in progress, don't expect it to work well or
+# properly right now.
+
+_accerso_get_repodir() {
+ local repodir
+ [[ -f ./profiles/repo_name ]] && repodir=$(readlink -f $(pwd))
+ [[ -z "${repodir}" && -f ../profiles/repo_name ]] \
+ && repodir=$(readlink -f $(pwd)/..)
+ [[ -z "${repodir}" && -f ../../profiles/repo_name ]] \
+ && repodir=$(readlink -f $(pwd)/../..)
+ [[ -z "${repodir}" ]] && return 1
+ echo "${repodir}"
+}
+
+_accerso() {
+ local cur prev opts
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ # Figure out what our repository dir is
+ for i in $(seq 0 ${COMP_CWORD}) ; do
+ if [[ ${COMP_WORDS[i]} == "-D" \
+ || ${COMP_WORDS[i]} == "--repository-dir" ]]
+ then
+ repodir=${COMP_WORDS[i+1]}
+ fi
+ done
+ [[ -z "${repodir}" ]] && repodir="$(_accerso_get_repodir)"
+
+ opts="--fetch -f \
+ --version -V \
+ --help -h \
+ --log-level \
+ --no-colour \
+ --no-color \
+ --repository-dir -D \
+ --download-dir -d \
+ --master-repository-dir \
+ --write-cache-dir \
+ --report-file -r"
+
+ case "${cur}" in
+ -*)
+ COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+ return 0
+ ;;
+ *)
+ case "${prev}" in
+ ## Enum operators
+ --log-level)
+ COMPREPLY=($(compgen -W "debug qa warning silent" -- "${cur}"))
+ return 0
+ ;;
+
+ --repository-dir|-D|--download-dir|-d|--master-repository-dir|--write-cache-dir)
+ _filedir -d
+ return 0
+ ;;
+
+ --report-file|-r)
+ _filedir
+ return 0
+ ;;
+
+ esac
+ ;;
+ esac
+}
+complete -o filenames -F _accerso accerso