github.com/osrg/gobgp/v3@v3.30.0/tools/completion/zsh/_gobgp (about)

     1  #compdef gobgp
     2  __af(){
     3      _arguments \
     4          '-a[address family]:<af>:(ipv4 ipv6 evpn encap rtc)'
     5  }
     6  
     7  __global(){
     8      local -a _global_arguments
     9      _global_arguments=(
    10          "rib"
    11      )
    12  
    13      _arguments : \
    14          '*:: :->command'
    15  
    16      if (( CURRENT == 1 )); then
    17          _describe -t commands "global command" _global_arguments
    18          return
    19      fi
    20  
    21      case "$words[1]" in
    22          rib)
    23              __af ;;
    24      esac
    25  }
    26  
    27  __neighbor(){
    28      : ${(A)_neighbors::=${=${$(gobgp -u ${${opt_args[-u]}:-127.0.0.1} -q neighbor)//\:/\\:}}}
    29  
    30      _arguments : \
    31          '*:: :->command'
    32  
    33      if (( CURRENT == 1 )); then
    34          _describe -t commands "neighbor selection" _neighbors
    35          return
    36      fi
    37  
    38      local -a _neighbor_arguments
    39      _neighbor_arguments=(
    40          "local"
    41          "adj-in"
    42          "adj-out"
    43          "reset"
    44          "softreset"
    45          "softresetin"
    46          "softresetout"
    47          "shutdown"
    48          "enable"
    49          "disable"
    50          "policy"
    51      )
    52  
    53      _arguments : \
    54          '*:: :->command'
    55  
    56      if (( CURRENT == 1 )); then
    57          _describe -t commands "neighbor command" _neighbor_arguments
    58          return
    59      fi
    60  
    61      case "$words[1]" in
    62          local) ;&
    63          adj-in) ;&
    64          adj-out) ;&
    65          reset) ;&
    66          softreset) ;&
    67          softresetin) ;&
    68          softresetout)
    69              __af ;;
    70      esac
    71  }
    72  
    73  local -a _gobgp_arguments
    74  _gobgp_arguments=(
    75      "global"
    76      "neighbor"
    77  )
    78  
    79  _arguments : \
    80      '-u[specifying an url (127.0.0.1)]:<host>:' \
    81      '-p[specifying a port]:<port>:' \
    82      '-d[use debug]' \
    83      '-q[use quiet]' \
    84      '-j[use json format to output format]' \
    85      '-h[Show this help message]' \
    86      '*:: :->command'
    87  
    88  if (( CURRENT == 1 )); then
    89      _describe -t commands "gobgp command" _gobgp_arguments
    90      return
    91  fi
    92  
    93  case "$words[1]" in
    94      global)
    95          __global ;;
    96      neighbor)
    97          __neighbor ;;
    98  esac