summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorChad Versace <chad.versace@intel.com>2015-05-20 23:20:48 -0700
committerChad Versace <chad.versace@intel.com>2015-05-22 18:43:29 -0700
commitcda1f5641d6e1f128c03698560379358df246fa8 (patch)
treea453ca4b090c3ac497b0c1a250afbd2dab6162f3 /misc
parent81d217d6eea07af32be7124b2ea9dbeae228b152 (diff)
Code drop
Diffstat (limited to 'misc')
-rw-r--r--misc/crucible-completion.bash55
1 files changed, 55 insertions, 0 deletions
diff --git a/misc/crucible-completion.bash b/misc/crucible-completion.bash
new file mode 100644
index 0000000..c6916d6
--- /dev/null
+++ b/misc/crucible-completion.bash
@@ -0,0 +1,55 @@
+__crucible_commands="bootstrap test help ls-tests ls-example-tests run version"
+
+__crucible_bootstrap()
+{
+ COMPREPLY=($(compgen -W "--help --width --height $($1 ls-tests)" -- ${COMP_WORDS[COMP_CWORD]}))
+}
+
+__crucible_help()
+{
+ COMPREPLY=($(compgen -W "$__crucible_commands" -- ${COMP_WORDS[COMP_CWORD]}))
+}
+
+__crucible_ls_tests()
+{
+ COMPREPLY=($(compgen -W "--help" -- ${COMP_WORDS[COMP_CWORD]}))
+}
+
+__crucible_run()
+{
+ COMPREPLY=($(compgen -W "--help --no-cleanup $($1 ls-tests)" -- ${COMP_WORDS[COMP_CWORD]}))
+}
+
+__crucible()
+{
+ local i c=1 command
+ local crucible_options="--help --version"
+
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ -*) ;;
+ *) command="$i"; break ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ case "${COMP_WORDS[COMP_CWORD]}" in
+ --*=*) COMPREPLY=() ;;
+ -*) COMPREPLY=($(compgen -P "" -W "$crucible_options" -- ${COMP_WORDS[COMP_CWORD]})) ;;
+ *) COMPREPLY=($(compgen -P "" -W "$__crucible_commands $crucible_options" -- ${COMP_WORDS[COMP_CWORD]})) ;;
+ esac
+ return
+ fi
+
+ case "$command" in
+ bootstrap) __crucible_bootstrap $1 ;;
+ help) __crucible_help ;;
+ ls-tests) __crucible_ls_tests $1 ;;
+ run) __crucible_run $1 ;;
+ *) COMPREPLY=() ;;
+ esac
+}
+
+complete -F __crucible crucible ./bin/crucible