diff options
Diffstat (limited to 'tools/completion/zsh/_gobgp')
-rw-r--r-- | tools/completion/zsh/_gobgp | 97 |
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 |