diff options
author | Thomas Haller <thaller@redhat.com> | 2013-11-11 14:46:47 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2013-11-11 15:15:56 +0100 |
commit | 8d7f6a28f640eecf54716c11a62eedfc941e1f48 (patch) | |
tree | c801fd3cc90e8d4572644777febe431537b78891 | |
parent | cd32796112fa6ce1696e85b40e7429501ccdba0f (diff) | |
download | NetworkManager-th/minor-cli-changes.tar.gz |
cli: improve bash completion to complete -h and --help aliasesth/minor-cli-changes
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | cli/completion/nmcli | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/cli/completion/nmcli b/cli/completion/nmcli index 86e42fec5a..c5e520362d 100644 --- a/cli/completion/nmcli +++ b/cli/completion/nmcli @@ -518,6 +518,15 @@ _nmcli_complete_COMMAND_CONNECTION() return 1 } +_nmcli_complete_commands() { + local command="$1" + shift + if [[ "x${command:0:1}" == 'x-' ]]; then + _nmcli_list "-h --help" + else + _nmcli_list "help $*" + fi +} _nmcli() { @@ -540,11 +549,9 @@ _nmcli() ;; g|ge|gen|gene|gener|genera|general) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_list "status permissions logging help" + _nmcli_complete_commands "$command" status permissions logging elif [[ ${#words[@]} -gt 2 ]]; then case "$command" in - s|st|sta|stat|statu|status | p|pe|per|perm|permi|permis|permiss|permissi|permissio|permission|permissions) - ;; l|lo|log|logg|loggi|loggin|logging) words=("${words[@]:2}") OPTIONS=(level domains) @@ -555,7 +562,7 @@ _nmcli() ;; n|ne|net|netw|netwo|networ|network|networki|networkin|networking) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_list "on off connectivity help" + _nmcli_complete_commands "$command" on off connectivity elif [[ ${#words[@]} -eq 3 ]]; then case "$command" in c|co|con|conn|conne|connec|connect|connecti|connectiv|connectivi|connectivit|connectivity) @@ -566,7 +573,7 @@ _nmcli() ;; r|ra|rad|radi|radio) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_list "all wifi wwan wimax help" + _nmcli_complete_commands "$command" all wifi wwan wimax elif [[ ${#words[@]} -eq 3 ]]; then case "$command" in a|al|all | w|wi|wif|wifi | ww|wwa|wwan | wim|wima|wimax) @@ -577,7 +584,7 @@ _nmcli() ;; c|co|con|conn|conne|connec|connect|connecti|connectio|connection) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_list "show up down add modify edit delete reload help" + _nmcli_complete_commands "$command" show up down add modify edit delete reload elif [[ ${#words[@]} -gt 2 ]]; then case "$command" in s|sh|sho|show) @@ -634,7 +641,7 @@ _nmcli() ;; a|ad|add) if [[ ${#words[@]} -eq 3 ]]; then - _nmcli_list "type ifname con-name autoconnect help" + _nmcli_complete_commands "${words[2]}" type ifname con-name autoconnect elif [[ ${#words[@]} -gt 3 ]]; then words=("${words[@]:2}") OPTIONS_TYPE= @@ -854,7 +861,7 @@ _nmcli() ;; d|de|dev|devi|devic|device) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_list "status show connect disconnect wifi wimax help" + _nmcli_complete_commands "$command" status show connect disconnect wifi wimax elif [[ ${#words[@]} -gt 2 ]]; then case "$command" in s|st|sta|stat|statu|status) |