-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completion: add preliminary completion file. category completion work…
…s, which is the important part
- Loading branch information
1 parent
606757c
commit 3c2a5be
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |