]>
Commit | Line | Data |
---|---|---|
682e043c | 1 | #compdef networkctl |
db9ecf05 | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
c54318c6 | 3 | |
c501ecd7 | 4 | (( $+functions[_networkctl_commands] )) || |
843cfcb1 ZJS |
5 | _networkctl_commands() { |
6 | local -a _networkctl_cmds | |
7 | _networkctl_cmds=( | |
c54318c6 | 8 | 'list:List existing links' |
6ff45bc1 OLM |
9 | 'status:Show information about the specified links' |
10 | 'lldp:Show Link Layer Discovery Protocol status' | |
11 | 'label:Show address labels' | |
12 | 'delete:Delete virtual netdevs' | |
11078998 RP |
13 | 'edit:Edit network configurations' |
14 | 'cat:Cat network configurations' | |
6ff45bc1 OLM |
15 | 'up:Bring devices up' |
16 | 'down:Bring devices down' | |
17 | 'renew:Renew dynamic configurations' | |
18 | 'forcerenew:Trigger DHCP reconfiguration of all connected clients' | |
19 | 'reconfigure:Reconfigure interfaces' | |
20 | 'reload:Reload .network and .netdev files' | |
843cfcb1 ZJS |
21 | ) |
22 | if (( CURRENT == 1 )); then | |
23 | _describe -t commands 'networkctl command' _networkctl_cmds | |
24 | else | |
25 | local curcontext="$curcontext" | |
26 | local -a _links | |
27 | cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}" | |
6ff45bc1 | 28 | case $cmd in |
11078998 RP |
29 | (list|status|up|down|cat|edit|lldp|delete|renew|forcerenew|reconfigure) |
30 | for link in ${(f)"$(_call_program links networkctl list --no-legend)"}; do _links+=($link[(w)2]:$link); done | |
6ff45bc1 | 31 | if [[ -n "$_links" ]]; then |
11078998 | 32 | _describe -t links 'links' _links _links $( [[ $cmd == (edit|cat) ]] && print -- -P@ ) |
6ff45bc1 OLM |
33 | else |
34 | _message "no links" | |
35 | fi | |
36 | ;; | |
37 | *) | |
38 | _message "no more options" | |
39 | ;; | |
40 | esac | |
c54318c6 | 41 | fi |
843cfcb1 | 42 | } |
c54318c6 | 43 | |
bfc2b05e YW |
44 | (( $+functions[_networkctl_get_json] )) || _networkctl_get_json() |
45 | { | |
46 | local -a _json_forms | |
47 | _json_forms=( $(networkctl --json=help 2>/dev/null) ) | |
48 | _values 'format' $_json_forms | |
49 | } | |
50 | ||
c54318c6 | 51 | _arguments \ |
20927c0e | 52 | '(-a --all)'{-a,--all}'[Show all links with status]' \ |
c54318c6 FS |
53 | '--no-pager[Do not pipe output into a pager]' \ |
54 | '--no-legend[Do not print the column headers]' \ | |
20927c0e EK |
55 | '(- *)'{-h,--help}'[Show this help]' \ |
56 | '(- *)--version[Show package version]' \ | |
57 | '--drop-in=[Use the given drop-in file name]:NAME' \ | |
11078998 | 58 | '--no-reload[Do not reload the network manager state when editing]' \ |
20927c0e | 59 | '--json=[Shows output formatted as JSON]:format:_networkctl_get_json' \ |
c501ecd7 | 60 | '*::networkctl commands:_networkctl_commands' |