| 1 |
# netplan(5) completion -*- shell-script -*- |
| 2 |
|
| 3 |
_netplan_completions_filter() { |
| 4 |
local words="$1" |
| 5 |
local cur=${COMP_WORDS[COMP_CWORD]} |
| 6 |
local result=() |
| 7 |
|
| 8 |
if [[ "${cur:0:1}" == "-" ]]; then |
| 9 |
echo "$words" |
| 10 |
|
| 11 |
else |
| 12 |
for word in $words; do |
| 13 |
[[ "${word:0:1}" != "-" ]] && result+=("$word") |
| 14 |
done |
| 15 |
|
| 16 |
echo "${result[*]}" |
| 17 |
|
| 18 |
fi |
| 19 |
} |
| 20 |
|
| 21 |
_netplan_completions() { |
| 22 |
local cur=${COMP_WORDS[COMP_CWORD]} |
| 23 |
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") |
| 24 |
local compline="${compwords[*]}" |
| 25 |
|
| 26 |
case "$compline" in |
| 27 |
'ip leases'*) |
| 28 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --root-dir")" -- "$cur" ) |
| 29 |
;; |
| 30 |
|
| 31 |
'generate'*) |
| 32 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --root-dir --mapping")" -- "$cur" ) |
| 33 |
;; |
| 34 |
|
| 35 |
'rebind'*) |
| 36 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug")" -- "$cur" ) |
| 37 |
;; |
| 38 |
|
| 39 |
'status'*) |
| 40 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug -a --all --diff --diff-only --root-dir --verbose -f --format $(ls /sys/class/net 2> /dev/null)")" -- "$cur" ) |
| 41 |
;; |
| 42 |
|
| 43 |
'apply'*) |
| 44 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --sriov-only --only-ovs-cleanup --state")" -- "$cur" ) |
| 45 |
;; |
| 46 |
|
| 47 |
'help'*) |
| 48 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help")" -- "$cur" ) |
| 49 |
;; |
| 50 |
|
| 51 |
'info'*) |
| 52 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --json --yaml")" -- "$cur" ) |
| 53 |
;; |
| 54 |
|
| 55 |
'get'*) |
| 56 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --root-dir")" -- "$cur" ) |
| 57 |
;; |
| 58 |
|
| 59 |
'set'*) |
| 60 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --origin-hint")" -- "$cur" ) |
| 61 |
;; |
| 62 |
|
| 63 |
'try'*) |
| 64 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug --config-file --timeout --state")" -- "$cur" ) |
| 65 |
;; |
| 66 |
|
| 67 |
'ip'*) |
| 68 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug help leases")" -- "$cur" ) |
| 69 |
;; |
| 70 |
|
| 71 |
*) |
| 72 |
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_netplan_completions_filter "-h --help --debug help apply generate get info ip set rebind status try")" -- "$cur" ) |
| 73 |
;; |
| 74 |
|
| 75 |
esac |
| 76 |
} && |
| 77 |
complete -F _netplan_completions netplan |
| 78 |
|
| 79 |
# ex: filetype=sh |