]>
Commit | Line | Data |
---|---|---|
c54318c6 | 1 | #compdef networkctl |
7059062c | 2 | # SPDX-License-Identifier: LGPL-2.1+ |
c54318c6 FS |
3 | |
4 | _networkctl_command(){ | |
5 | local -a _networkctl_cmds | |
6 | _networkctl_cmds=( | |
7 | 'list:List existing links' | |
8 | 'status:Show information about the specified links' | |
9 | 'lldp:Show Link Layer Discovery Protocol status' | |
a5be8dab | 10 | 'label:Show address labels' |
c54318c6 FS |
11 | ) |
12 | if (( CURRENT == 1 )); then | |
13 | _describe -t commands 'networkctl command' _networkctl_cmds | |
14 | else | |
15 | local curcontext="$curcontext" | |
16 | local -a _links | |
17 | cmd="${${_networkctl_cmds[(r)$words[1]:*]%%:*}}" | |
18 | if [ $cmd = "status" ]; then | |
673fca32 | 19 | _links=( "${(foa)$(networkctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $2,$0}' 2>/dev/null)}" ) |
c54318c6 FS |
20 | if [[ -n "$_links" ]]; then |
21 | _describe -t links 'links' _links | |
22 | else | |
23 | _message "no links" | |
24 | fi | |
25 | else | |
26 | _message "no more options" | |
27 | fi | |
28 | fi | |
29 | } | |
30 | ||
31 | _arguments \ | |
32 | {-a,--all}'[Show all links with status]' \ | |
33 | '--no-pager[Do not pipe output into a pager]' \ | |
34 | '--no-legend[Do not print the column headers]' \ | |
35 | {-h,--help}'[Show this help]' \ | |
36 | '--version[Show package version]' \ | |
37 | '*::networkctl commands:_networkctl_command' |