diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f2621414ee5f2f601424c22f00e207903e3b6104 (patch) | |
tree | 56a856dafd1ca684bb23263cacaa723ee4f404fc /completions/_nmcli | |
parent | Adding debian version 1:2.11-8. (diff) | |
download | bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.tar.xz bash-completion-f2621414ee5f2f601424c22f00e207903e3b6104.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/_nmcli')
-rw-r--r-- | completions/_nmcli | 116 |
1 files changed, 51 insertions, 65 deletions
diff --git a/completions/_nmcli b/completions/_nmcli index eac285b..835db99 100644 --- a/completions/_nmcli +++ b/completions/_nmcli @@ -3,83 +3,76 @@ # Use of this file is deprecated. Upstream completion is available in # NetworkManager >= 0.9.8.0, use that instead. -_nmcli_list() +_comp_cmd_nmcli__con_id() { - COMPREPLY=($(compgen -W '$1' -- "$cur")) + _comp_compgen_split -l -- "$(nmcli con list 2>/dev/null | + tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')" } -_nmcli_con_id() +_comp_cmd_nmcli__con_uuid() { - local IFS=$'\n' - COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | - tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur")) + _comp_compgen_split -- "$(nmcli con list 2>/dev/null | + tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')" } -_nmcli_con_uuid() +_comp_cmd_nmcli__ap_ssid() { - COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) + _comp_compgen_split -l -- "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')" } -_nmcli_ap_ssid() +_comp_cmd_nmcli__ap_bssid() { - local IFS=$'\n' - COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | - tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur")) + _comp_compgen_split -- "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')" } -_nmcli_ab_bssid() +_comp_cmd_nmcli() { - COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) -} - -_nmcli() -{ - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in -m | --mode) - COMPREPLY=($(compgen -W 'tabular multiline' -- "$cur")) + _comp_compgen -- -W 'tabular multiline' return ;; -f | --fields) - COMPREPLY=($(compgen -W 'all common' -- "$cur")) + _comp_compgen -- -W 'all common' return ;; -e | --escape) - _nmcli_list "yes no" + _comp_compgen -- -W "yes no" return ;; id) - _nmcli_con_id + _comp_cmd_nmcli__con_id return ;; uuid) - _nmcli_con_uuid + _comp_cmd_nmcli__con_uuid return ;; iface) - _available_interfaces + _comp_compgen_available_interfaces return ;; bssid) - _nmcli_ab_bssid + _comp_cmd_nmcli__ap_bssid return ;; wep-key-type) - _nmcli_list "key phrase" + _comp_compgen -- -W "key phrase" return ;; esac if ((cword == 1)); then if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--terse --pretty --mode --fields - --escape --version --help' -- "$cur")) + _comp_compgen -- -W '--terse --pretty --mode --fields --escape + --version --help' else - COMPREPLY=($(compgen -W "nm con dev" -- "$cur")) + _comp_compgen -- -W "nm con dev" fi else local object=${words[1]} @@ -89,71 +82,67 @@ _nmcli() nm) case $command in enable) - _nmcli_list "true false" + _comp_compgen -- -W "true false" return ;; sleep) - _nmcli_list "true false" + _comp_compgen -- -W "true false" return ;; wifi) - _nmcli_list "on off" + _comp_compgen -- -W "on off" return ;; wwan) - _nmcli_list "on off" + _comp_compgen -- -W "on off" return ;; wimax) - _nmcli_list "on off" + _comp_compgen -- -W "on off" return ;; esac - COMPREPLY=($(compgen -W 'status permissions enable sleep - wifi wwan wimax' -- "$cur")) + _comp_compgen -- -W 'status permissions enable sleep wifi wwan + wimax' ;; con) case $command in list) - COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) + _comp_compgen -- -W 'id uuid' return ;; up) if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--nowait --timeout' \ - -- "$cur")) + _comp_compgen -- -W '--nowait --timeout' else - COMPREPLY=($(compgen -W 'id uuid iface ap nsp' \ - -- "$cur")) + _comp_compgen -- -W 'id uuid iface ap nsp' fi return ;; down) - COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) + _comp_compgen -- -W 'id uuid' return ;; delete) - COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) + _comp_compgen -- -W 'id uuid' return ;; esac - COMPREPLY=($(compgen -W 'list status up down delete' \ - -- "$cur")) + _comp_compgen -- -W 'list status up down delete' ;; dev) case $command in list) - COMPREPLY=($(compgen -W 'iface' -- "$cur")) + _comp_compgen -- -W 'iface' return ;; disconnect) if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--nowait --timeout' \ - -- "$cur")) + _comp_compgen -- -W '--nowait --timeout' else - COMPREPLY=($(compgen -W 'iface' -- "$cur")) + _comp_compgen -- -W 'iface' fi return ;; @@ -162,40 +151,37 @@ _nmcli() case $subcommand in list) - COMPREPLY=($(compgen -W 'iface bssid' \ - -- "$cur")) + _comp_compgen -- -W 'iface bssid' return ;; connect) if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '--private - --nowait --timeout' -- "$cur")) + _comp_compgen -- -W '--private --nowait + --timeout' else if [[ $prev == "connect" ]]; then - _nmcli_ap_ssid + _comp_cmd_nmcli__ap_ssid else - COMPREPLY=($(compgen -W 'password - wep-key-type iface bssid name' \ - -- "$cur")) + _comp_compgen -- -W 'password + wep-key-type iface bssid name' fi fi return ;; esac - COMPREPLY=($(compgen -W 'list connect' -- "$cur")) + _comp_compgen -- -W 'list connect' return ;; esac - COMPREPLY=($(compgen -W 'status list disconnect wifi' \ - -- "$cur")) + _comp_compgen -- -W 'status list disconnect wifi' ;; esac fi } && - complete -F _nmcli nmcli + complete -F _comp_cmd_nmcli nmcli # ex: filetype=sh |