summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-05-18 06:54:03 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-05-18 06:54:03 +0000
commit772dbed046cc75891cc37d7a34a85d94d6e40e8b (patch)
treec2d58970951ff077a12e4a8282c27d6f9c7648d6
parentbbb57319134b60d60c41be5273f235d8c4c89651 (diff)
tools: add zsh completion for gobgp cli
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--tools/completion/zsh/_gobgp97
1 files changed, 97 insertions, 0 deletions
diff --git a/tools/completion/zsh/_gobgp b/tools/completion/zsh/_gobgp
new file mode 100644
index 00000000..34d78e7e
--- /dev/null
+++ b/tools/completion/zsh/_gobgp
@@ -0,0 +1,97 @@
+#compdef gobgp
+__af(){
+ _arguments \
+ '-a[address family]:<af>:(ipv4 ipv6 evpn encap rtc)'
+}
+
+__global(){
+ local -a _global_arguments
+ _global_arguments=(
+ "rib"
+ )
+
+ _arguments : \
+ '*:: :->command'
+
+ if (( CURRENT == 1 )); then
+ _describe -t commands "global command" _global_arguments
+ return
+ fi
+
+ case "$words[1]" in
+ rib)
+ __af ;;
+ esac
+}
+
+__neighbor(){
+ : ${(A)_neighbors::=${=${$(gobgp -u ${${opt_args[-u]}:-127.0.0.1} -q neighbor)//\:/\\:}}}
+
+ _arguments : \
+ '*:: :->command'
+
+ if (( CURRENT == 1 )); then
+ _describe -t commands "neighbor selection" _neighbors
+ return
+ fi
+
+ local -a _neighbor_arguments
+ _neighbor_arguments=(
+ "local"
+ "adj-in"
+ "adj-out"
+ "reset"
+ "softreset"
+ "softresetin"
+ "softresetout"
+ "shutdown"
+ "enable"
+ "disable"
+ )
+
+ _arguments : \
+ '*:: :->command'
+
+ if (( CURRENT == 1 )); then
+ _describe -t commands "neighbor command" _neighbor_arguments
+ return
+ fi
+
+ case "$words[1]" in
+ local) ;&
+ adj-in) ;&
+ adj-out) ;&
+ reset) ;&
+ softreset) ;&
+ softresetin) ;&
+ softresetout)
+ __af ;;
+ esac
+}
+
+local -a _gobgp_arguments
+_gobgp_arguments=(
+ "global"
+ "neighbor"
+)
+
+_arguments : \
+ '-u[specifying an url (127.0.0.1)]:<host>:' \
+ '-p[specifying a port]:<port>:' \
+ '-d[use debug]' \
+ '-q[use quiet]' \
+ '-j[use json format to output format]' \
+ '-h[Show this help message]' \
+ '*:: :->command'
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "gobgp command" _gobgp_arguments
+ return
+fi
+
+case "$words[1]" in
+ global)
+ __global ;;
+ neighbor)
+ __neighbor ;;
+esac