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