bash completion: make command list dynamic
authorGuido Günther <agx@sigxcpu.org>
Sun, 24 Aug 2014 09:24:52 +0000 (11:24 +0200)
committerJun Wang <junbill.wang@samsung.com>
Tue, 26 Jan 2016 15:56:51 +0000 (23:56 +0800)
Use "gbp --list-cmds" so we don't have to hardcode the available
commands and get support for the RPM ones as they show up.

debian/git-buildpackage.bash-completion

index c012704..053b933 100644 (file)
@@ -27,6 +27,12 @@ _gbp_options ()
 }
 
 
+_gbp_commands ()
+{
+    gbp --list-cmds | sed -ne  's/^ \+\([a-z\-]\+\) \-.*/\1/p'
+}
+
+
 _gbp_comp ()
 {
     local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -208,15 +214,7 @@ have gbp &&
 _gbp ()
 {
     local cur="${COMP_WORDS[COMP_CWORD]}"
-    local commands="buildpackage       \
-                    clone              \
-                    create-remote-repo \
-                    dch                \
-                    import-dsc         \
-                    import-dscs        \
-                    import-orig        \
-                    pq                 \
-                    pull"
+    local commands=$(_gbp_commands)
     local func
 
     command=$(_gbp_find_cmd_on_cmdline "$commands")