aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2006-11-12 22:55:14 +0000
committerAvatar Mike Kelly <pioto@pioto.org> 2006-11-12 22:55:14 +0000
commitab04957a2c6f4d9fd4ca14ec75da4c39734d2518 (patch)
treef767b1917f8cdd5de2f28229d912b0d182ad87aa
parenta2f87fc332f4aee3ec13f7f8d0e413c1c57d00b1 (diff)
downloadpaludis-ab04957a2c6f4d9fd4ca14ec75da4c39734d2518.tar.gz
paludis-ab04957a2c6f4d9fd4ca14ec75da4c39734d2518.tar.xz
Distribute the bash-completion scripts. Add an adjutrix script.
-rw-r--r--Makefile.am2
-rw-r--r--bash-completion/Makefile.am1
-rw-r--r--bash-completion/adjutrix108
-rw-r--r--configure.ac1
4 files changed, 111 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index ca8b4f7..0ed8d14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \
config.h config.h.in INSTALL COPYING
AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options
EXTRA_DIST = autogen.bash automake-deps-hack.tmp
-SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect
+SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect bash-completion
DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby --enable-glsa --with-ruby-install-dir='$${DESTDIR}$${prefix}/ruby_dir'
diff --git a/bash-completion/Makefile.am b/bash-completion/Makefile.am
new file mode 100644
index 0000000..c3a49fc
--- /dev/null
+++ b/bash-completion/Makefile.am
@@ -0,0 +1 @@
+noinst_DATA = paludis adjutrix
diff --git a/bash-completion/adjutrix b/bash-completion/adjutrix
new file mode 100644
index 0000000..b406b7b
--- /dev/null
+++ b/bash-completion/adjutrix
@@ -0,0 +1,108 @@
+# Bash completion function for adjutrix
+# Written by Mike Kelly
+# 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.
+
+_adjutrix_get_repodir() {
+ local repodir
+ [[ -f ./profiles/repo_name ]] && repodir=$(readlink -f $(pwd))
+ [[ -f ../profiles/repo_name ]] && repodir=$(readlink -f $(pwd)/..)
+ [[ -f ../../profiles/repo_name ]] && repodir=$(readlink -f $(pwd)/../..)
+ [[ -z "${repodir}" ]] && return 1
+ echo "${repodir}"
+}
+
+_adjutrix() {
+ local cur prev opts repodir
+ 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="$(_adjutrix_get_repodir)"
+
+ opts="--find-stable-candidates -s \
+ --find-dropped-keywords -d \
+ --find-insecure-packages -i \
+ --keyword-graph -k \
+ --reverse-deps -r \
+ --display-profiles-use -u \
+ --display-default-system-resolution -S \
+ --version -V \
+ --help -h \
+ --log-level \
+ --no-colour \
+ --no-color \
+ --repository-dir -D \
+ --category -C \
+ --package -P \
+ --profile -p \
+ --unstable -U"
+
+ 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
+ ;;
+
+ --category)
+ [[ -z "${repodir}" ]] && return 0
+ COMPREPLY=($(compgen -W "$(< ${repodir}/profiles/categories)" -- "${cur}"))
+ return 0
+ ;;
+ --package)
+ [[ -z "${repodir}" ]] && return 0
+ # borrowed from the gentoo bashcomp script
+ local p
+ COMPREPLY=($(compgen -W "$(\
+ builtin cd ${repodir}; \
+ for p in *-*/${cur}*; do \
+ [[ -d ${p} ]] && \
+ echo ${p##*/} ; \
+ done)" -- "${cur}"))
+ return 0
+ ;;
+
+ --find-stable-candidates|-s|--find-dropped-keywords|-d)
+ [[ -z "${repodir}" ]] && return 0
+ COMPREPLY=($(compgen -W "$(< ${repodir}/profiles/arch.list)" -- "${cur}"))
+ return 0
+ ;;
+
+ --repository-dir|-D)
+ COMPREPLY=($(compgen -o filenames -d -- "${cur}"))
+ return 0
+ ;;
+
+ --profile|-p)
+ COMPREPLY=($(compgen -W "$(\
+ grep -ve ^\# -ve ^\$ ${repodir}/profiles/profiles.desc \
+ |awk '{print $2}')" -- "${cur}"))
+ return 0
+ ;;
+
+ *)
+ COMPREPLY=()
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+}
+complete -F _adjutrix adjutrix
diff --git a/configure.ac b/configure.ac
index 0422ee1..3970804 100644
--- a/configure.ac
+++ b/configure.ac
@@ -670,6 +670,7 @@ dnl {{{ output
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
Makefile
+ bash-completion/Makefile
cran/Makefile
doc/Makefile
doc/doxygen.conf