diff options
author | Thomas Haller <thaller@redhat.com> | 2015-02-23 18:29:18 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-03-02 14:02:58 +0100 |
commit | 81c420dc6251f54c3358411093bcc902166fdb7a (patch) | |
tree | 9be76feab5e5ad22cb3f6a0dec6fd4ed4954565b /clients | |
parent | a94081b70f05873a321e9e80acb0ca9fde38a63e (diff) | |
download | NetworkManager-81c420dc6251f54c3358411093bcc902166fdb7a.tar.gz |
cli/completion: add completion for --order option
This does not yet work, because the --order option
contains colons which bash completion considers as
separaters.
For now, implement it and ignore that problem. It
works correctly until you specify more then one
order-columns separated by colon.
https://bugzilla.gnome.org/show_bug.cgi?id=738613
Fixes: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/nmcli-completion | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion index 8443844f9a..301ce9d266 100644 --- a/clients/cli/nmcli-completion +++ b/clients/cli/nmcli-completion @@ -170,6 +170,33 @@ _nmcli_compl_OPTIONS() ask) _nmcli_array_delete_at words 0 ;; + order) + if [[ "${#words[@]}" -eq 2 ]]; then + local ord="${words[1]}" + local ord_sta="" + local i + local c=() + + # FIXME: currently the completion considers colon as separator + # for words. Hence the following doesn't work as $ord will + # not contain any colons at this point. + # See https://bugzilla.gnome.org/show_bug.cgi?id=745157 + + if [[ $ord = *":"* ]]; then + ord_sta="${ord%:*}:" + ord="${ord##*:}" + fi + if [[ $ord = [-+]* ]]; then + ord_sta="$ord_sta${ord:0:1}" + fi + for i in active name type path; do + c=("${c[@]}" "$ord_sta$i") + done + _nmcli_list "${c[*]}" + return 0 + fi + _nmcli_array_delete_at words 0 1 + ;; show-secrets) _nmcli_array_delete_at words 0 ;; @@ -785,11 +812,11 @@ _nmcli() case "$command" in s|sh|sho|show) if [[ ${#words[@]} -eq 3 ]]; then - _nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME)")" active show-secrets + _nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME)")" active show-secrets order elif [[ ${#words[@]} -gt 3 ]]; then _nmcli_array_delete_at words 0 1 - LONG_OPTIONS=(help active show-secrets) + LONG_OPTIONS=(help active show-secrets order) HELP_ONLY_AS_FIRST=1 _nmcli_compl_OPTIONS i=$? |