#compdef gobgp __af(){ _arguments \ '-a[address family]::(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)]::' \ '-p[specifying a 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