Permalink
Browse files

completion: add preliminary completion file. category completion work…

…s, which is the important part
  • Loading branch information...
1 parent 606757c commit 3c2a5be2ebec343fe6e537bb4202d80933673e3b @falconindy committed Jul 3, 2010
Showing with 38 additions and 0 deletions.
  1. +38 −0 clockwerk.bash_completion
View
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+_clockwerk() {
+ local cur prev actions categories src ng_set
+
+ # save current nullglob setting and turn it on
+ ng_set=$(shopt -p nullglob)
+ shopt -s nullglob
+
+ declare -a COMPREPLY
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+
+ # Valid actions
+ actions="job category status report"
+
+ jobact="start stop modify delete"
+
+ catact="list add delete modify"
+
+ [[ $prev == ${COMP_WORDS[0]} ]] && COMPREPLY=( $(compgen -W "$actions" -- $cur ) ) && return
+
+ case ${COMP_WORDS[1]} in
+ "job") COMPREPLY=( $(compgen -W "$jobact" -- $cur ) ) ;;
+ "category") COMPRELY=( $(compgen -W "$catact" -- $cur ) ) ;;
+ esac
+
+ if [[ ${COMP_WORDS[1]} = "job" && $prev = "start" ]]; then
+ COMPREPLY=( $(compgen -W "$(${COMP_WORDS[0]} category list)" -- $cur ) )
+ fi
+
+ # restore the previous nullglob setting
+ $ng_set
+
+}
+
+complete -F _clockwerk clockwerk

0 comments on commit 3c2a5be

Please sign in to comment.