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