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