From 3a8582dc6786dfc924216df3bd3d3feb62dfe075 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 22 Oct 2007 22:55:06 -0400 Subject: [PATCH] Add bash completion script. --- bash-completion.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) create mode 100644 bash-completion.sh diff --git a/bash-completion.sh b/bash-completion.sh new file mode 100644 index 0000000..ff6f274 --- /dev/null +++ b/bash-completion.sh @@ -0,0 +1,37 @@ +__razor_commands () { + COMPREPLY=($(compgen -W "list-requires list-provides list-files list-file-packages what-requires what-provides import-yum import-rpmdb validate update diff" -- $1)) +} + +__razor_packages () { + COMPREPLY=($(compgen -W "$(./razor list)" -- $1)) +} + +__razor_files() { + COMPREPLY=($(compgen -W "$(./razor list-files)" -- $1)) +} + +__razor_requires() { + echo requires + COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1)) +} + +__razor_provides() { + COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1)) +} + +__razor() { + local cur="${COMP_WORDS[COMP_CWORD]}" + + if [ $COMP_CWORD = 1 ]; then + __razor_commands $cur + else + case "${COMP_WORDS[1]}" in + list-requires|list-provides) __razor_packages $cur ;; + list-files|list-file-packages) __razor_files $cur ;; + what-requires) __razor_requires $cur ;; + what-provides) __razor_provides $cur ;; + esac + fi +} + +complete -F __razor razor -- 1.7.1