summaryrefslogtreecommitdiff
path: root/data/bash-completion.sh
diff options
context:
space:
mode:
Diffstat (limited to 'data/bash-completion.sh')
-rw-r--r--data/bash-completion.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/data/bash-completion.sh b/data/bash-completion.sh
new file mode 100644
index 0000000..a9c4221
--- /dev/null
+++ b/data/bash-completion.sh
@@ -0,0 +1,47 @@
+__razor_commands () {
+ local IFS=$'\n'
+ COMPREPLY=($(IFS=: compgen -S' ' -W "info:list-requires:list-provides:list-files:list-file-packages:list-package-files:what-requires:what-provides:import-yum:import-rpmdb:validate:update:diff:install:init:download" -- $1))
+}
+
+__razor_packages () {
+ local IFS=$'\n'
+
+ COMPREPLY=($(./razor list --only-names "$1*" | while read p; do echo "$p "; done))
+}
+
+__razor_upstream_packages () {
+ local IFS=$'\n'
+
+ COMPREPLY=($(RAZOR_REPO=rawhide.repo ./razor list --only-names "$1*" | while read p; do echo "$p "; done))
+}
+
+__razor_files() {
+ COMPREPLY=($(./razor list-files "$1*"))
+}
+
+__razor_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
+ info|list-requires|list-provides|list-package-files)
+ __razor_packages $cur ;;
+ list-files|list-file-packages) __razor_files $cur ;;
+ what-requires) __razor_requires $cur ;;
+ what-provides) __razor_provides $cur ;;
+ install|download) __razor_upstream_packages $cur ;;
+ esac
+ fi
+}
+
+complete -o nospace -F __razor razor