Bash completion script, list-projects, list-contexts commands.

* list-projects lists all the projects in the repo.
* list-contexts lists all the context in the repo.
* Created a bash completion script to allow auto-complete for GTD.
This commit is contained in:
Joanthan Bernard
2014-12-16 14:04:58 -06:00
parent a780d972f1
commit 4c5f514fb4
3 changed files with 90 additions and 4 deletions

View File

@ -0,0 +1,39 @@
_gtd()
{
local cur prev topOpts debugOpts logLevels
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
topOpts="help process done calendar list-copies new tickler list debug delegate rename-project list-projects list-contexts"
debugOpts="state loglevel"
logLevels="TRACE DEBUG INFO WARN ERROR"
case "${prev}" in
help)
COMPREPLY=( $(compgen -W "${topOpts}" -- ${cur}) )
return 0
;;
done|list-copies|delegate)
COMPREPLY=( $(compgen -f ${cur}) )
return 0
;;
ls|list)
COMPREPLY=( $(gtd list-projects) $(gtd list-contexts) )
return 0
;;
debug)
COMPREPLY=( $(compgen -W "${debugOpts}" -- ${cur}) )
return 0
;;
loglevel)
COMPREPLY=( $(compgen -W "${logLevels}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=( $(compgen -W "${topOpts}" -- ${cur}) )
return 0
}
complete -F _gtd gtd