summaryrefslogtreecommitdiffhomepage
path: root/tools/completion/zsh/_gobgp
blob: 99689e03c2173141a8bacfacd0dc8d2ef30ce8ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#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"
        "policy"
    )

    _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