From 037303d8bc756848facdda9ee8081a7847ef6949 Mon Sep 17 00:00:00 2001
From: aviau <alexandre.viau@savoirfairelinux.com>
Date: Mon, 22 Dec 2014 10:34:45 -0500
Subject: [PATCH] Added bash completion script

Change-Id: I4faa380ee013b27755eeb49abed0cdbfbd1485d9
---
 tools/surveil.bash_completion | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 tools/surveil.bash_completion

diff --git a/tools/surveil.bash_completion b/tools/surveil.bash_completion
new file mode 100644
index 0000000..a3876ef
--- /dev/null
+++ b/tools/surveil.bash_completion
@@ -0,0 +1,27 @@
+# bash completion for openstack surveil
+
+_surveil_opts="" # lazy init
+_surveil_flags="" # lazy init
+_surveil_opts_exp="" # lazy init
+_surveil()
+{
+    local cur prev kbc
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    if [ "x$_surveil_opts" == "x" ] ; then
+        kbc="`surveil bash-completion | sed -e "s/ -h / /"`"
+        _surveil_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
+        _surveil_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
+        _surveil_opts_exp="`echo $_surveil_opts | sed -e "s/[ ]/|/g"`"
+    fi
+
+    if [[ " ${COMP_WORDS[@]} " =~ " "($_surveil_opts_exp)" " && "$prev" != "help" ]] ; then
+        COMPREPLY=($(compgen -W "${_surveil_flags}" -- ${cur}))
+    else
+        COMPREPLY=($(compgen -W "${_surveil_opts}" -- ${cur}))
+    fi
+    return 0
+}
+complete -o default -F _surveil surveil