diff options
| author | Michael Biebl <biebl@debian.org> | 2016-08-26 02:18:32 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-08-26 02:18:32 +0200 |
| commit | 7514efc2f38c9ace4557d4e69d68e7d380389030 (patch) | |
| tree | 7fb00fda86cfcc2ca377f191633a7cfdbfea7ca3 /clients/cli/nmcli-completion | |
| parent | d6201f5d8daada3d64a0a3e0038e14eebec683ce (diff) | |
Imported Upstream version 1.4.0 upstream/1.4.0
Diffstat (limited to 'clients/cli/nmcli-completion')
| -rw-r--r-- | clients/cli/nmcli-completion | 291 |
1 files changed, 31 insertions, 260 deletions
diff --git a/clients/cli/nmcli-completion b/clients/cli/nmcli-completion index ffab7d8b..e78ab85c 100644 --- a/clients/cli/nmcli-completion +++ b/clients/cli/nmcli-completion @@ -123,6 +123,8 @@ _nmcli_compl_match_option() S="${S:2}" elif [[ "${S:0:1}" == "-" ]]; then S="${S:1}" + else + return 1 fi for V; do case "$V" in @@ -231,14 +233,14 @@ _nmcli_compl_OPTIONS() mode) if [[ "${#words[@]}" -eq 2 ]]; then _nmcli_list "tabular multiline" - return 0 + return 0 fi _nmcli_array_delete_at words 0 1 ;; colors) if [[ "${#words[@]}" -eq 2 ]]; then _nmcli_list "yes no auto" - return 0 + return 0 fi _nmcli_array_delete_at words 0 1 ;; @@ -249,21 +251,21 @@ _nmcli_compl_OPTIONS() connection 802-3-ethernet 802-1x 802-11-wireless 802-11-wireless-security ipv4 ipv6 serial ppp pppoe gsm cdma bluetooth 802-11-olpc-mesh vpn wimax infiniband bond vlan adsl bridge bridge-port team team-port dcb tun ip-tunnel macvlan vxlan GENERAL IP4 DHCP4 IP6 DHCP6 VPN profile active" - return 0 + return 0 fi _nmcli_array_delete_at words 0 1 ;; escape) if [[ "${#words[@]}" -eq 2 ]]; then _nmcli_list "no yes" - return 0 + return 0 fi _nmcli_array_delete_at words 0 1 ;; wait) if [[ "${#words[@]}" -eq 2 ]]; then _nmcli_list "" - return 0 + return 0 fi _nmcli_array_delete_at words 0 1 ;; @@ -328,13 +330,13 @@ _nmcli_compl_ARGS() case "${WORD0}" in level) if [[ "${#words[@]}" -eq 2 ]]; then - _nmcli_list "OFF ERR WARN INFO DEBUG TRACE" + _nmcli_list "OFF ERR WARN INFO DEBUG TRACE KEEP" return 0 fi ;; domains) if [[ "${#words[@]}" -eq 2 ]]; then - local OPTIONS_DOM=(ALL DEFAULT PLATFORM RFKILL ETHER WIFI BT MB DHCP4 DHCP6 PPP WIFI_SCAN IP4 IP6 AUTOIP4 DNS VPN SHARING SUPPLICANT AGENTS SETTINGS SUSPEND CORE DEVICE OLPC WIMAX INFINIBAND FIREWALL ADSL BOND VLAN BRIDGE DBUS_PROPS TEAM CONCHECK DCB DISPATCH) + local OPTIONS_DOM=(ALL DEFAULT DHCP IP PLATFORM RFKILL ETHER WIFI BT MB DHCP4 DHCP6 PPP WIFI_SCAN IP4 IP6 AUTOIP4 DNS VPN SHARING SUPPLICANT AGENTS SETTINGS SUSPEND CORE DEVICE OLPC WIMAX INFINIBAND FIREWALL ADSL BOND VLAN BRIDGE DBUS_PROPS TEAM CONCHECK DCB DISPATCH AUDIT SYSTEMD VPN_PLUGIN) if [[ "${words[1]}" != "" ]]; then # split the comma separaeted domain string into its parts LOGD @@ -761,21 +763,14 @@ _nmcli_compl_COMMAND_nl() { _nmcli_compl_PROPERTIES() { - while [[ "${#words[@]}" -gt 0 ]]; do - if [[ ${#words[@]} -le 1 ]]; then - local PREFIX="" - - if [[ "${words[0]:0:1}" == [+-] ]]; then - PREFIX="${words[0]:0:1}" - fi - _nmcli_list_nl "$(echo -e 'print\nquit\nyes' |nmcli c edit "$@" 2>/dev/null |awk -F: '/\..*:/ {print "'$PREFIX'"$1}')" - return 0 - elif [[ ${#words[@]} -le 2 ]]; then + while [[ ${#words[@]} -gt 0 ]]; do + if [[ ${#words[@]} -eq 1 ]]; then + _nmcli_list_nl "$(nmcli --complete-args connection modify "$@" "${words[@]}" 2>/dev/null)" return 0 fi _nmcli_array_delete_at words 0 1 done - _nmcli_list_nl "$(echo -e 'print\nquit\nyes' |nmcli c edit "$@" 2>/dev/null |awk -F: '/\..*:/ {print $1}')" + return 0 } _nmcli() @@ -802,22 +797,18 @@ _nmcli() cur='' fi - local OPTIONS_UNKNOWN_OPTION OPTIONS_TYPE OPTIONS_TYPED OPTIONS OPTIONS_MANDATORY COMMAND_ARGS_WAIT_OPTIONS OPTIONS_IP OPTIONS_MANDATORY OPTIONS_NEXT_GROUP OPTIONS_SEP OPTIONS_REPEATABLE - local COMMAND_CONNECTION_TYPE COMMAND_CONNECTION_ID OPTIONS_MANDATORY_IFNAME HELP_ONLY_AS_FIRST - local COMMAND_CONNECTION_ACTIVE="" + local OPTIONS OPTIONS_UNKNOWN_OPTION OPTIONS_TYPE OPTIONS_TYPED OPTIONS_IP OPTIONS_NEXT_GROUP \ + OPTIONS_SEP OPTIONS_REPEATABLE OPTIONS_MANDATORY OPTIONS_MANDATORY_IFNAME \ + COMMAND_ARGS_WAIT_OPTIONS COMMAND_CONNECTION_TYPE COMMAND_CONNECTION_ID \ + COMMAND_CONNECTION_ACTIVE="" HELP_ONLY_AS_FIRST="" \ + LONG_OPTIONS=(terse pretty mode fields colors escape ask show-secrets wait version help) - HELP_ONLY_AS_FIRST= - local LONG_OPTIONS=(terse pretty mode fields colors escape ask show-secrets wait version help) _nmcli_compl_OPTIONS i=$? - if [[ "$HELP_ONLY_AS_FIRST" == '0' ]]; then - # got a --help. No more completion. - return 0 - fi - case $i in 0) + # We have just completed an option or got an --help: terminate. return 0 ;; 1) @@ -1005,238 +996,10 @@ _nmcli() ;; a|ad|add) if [[ ${#words[@]} -eq 3 ]]; then - _nmcli_compl_COMMAND "${words[2]}" type ifname con-name autoconnect master slave-type - elif [[ ${#words[@]} -gt 3 ]]; then + _nmcli_compl_COMMAND_nl "${words[2]}" "$(nmcli --complete-args connection add "" 2>/dev/null)" + else _nmcli_array_delete_at words 0 1 - - LONG_OPTIONS=(help) - HELP_ONLY_AS_FIRST=1 - _nmcli_compl_OPTIONS - case $? in - 0) - return 0 - ;; - 1) - if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then - _nmcli_compl_COMMAND "${words[2]}" type ifname con-name autoconnect master slave-type - fi - return 0 - ;; - esac - - OPTIONS_TYPE= - OPTIONS=(type ifname con-name autoconnect save master slave-type) - OPTIONS_MANDATORY=(type ifname) - COMMAND_ARGS_WAIT_OPTIONS=1 - OPTIONS_MANDATORY_IFNAME=1 - _nmcli_compl_ARGS && return 0 - - OPTIONS_MANDATORY_IFNAME= - if _nmcli_array_has_value OPTIONS "${OPTIONS_MANDATORY[@]}"; then - # we still have some missing mandatory options... - if [[ "$OPTIONS_UNKNOWN_OPTION" != '' ]]; then - if ! _nmcli_array_has_value OPTIONS "${OPTIONS_UNKNOWN_OPTION:1}"; then - # if we encountered an unknown option while having mandatory - # options, just return. - return 0 - fi - fi - _nmcli_list "$(echo "${OPTIONS[@]}")" - return 0 - fi - - OPTIONS_IP=(ip4 ip6 gw4 gw6) - OPTIONS_SEP=(--) - OPTIONS_MANDATORY=() - case "$OPTIONS_TYPE" in - 802-3|802-3-|802-3-e|802-3-et|802-3-eth|802-3-ethe|802-3-ether|802-3-ethern|802-3-etherne|802-3-ethernet| \ - e|et|eth|ethe|ether|ethern|etherne|ethernet) - OPTIONS_TYPE=ethernet - OPTIONS_TYPED=(mac cloned-mac mtu) - ;; - 802-11-w|802-11-wi|802-11-wir|802-11-wire|802-11-wirel|802-11-wirele|802-11-wireles|802-11-wireless| \ - wif|wifi) - OPTIONS_TYPE=wifi - OPTIONS_TYPED=(ssid mac cloned-mac mtu mode) - OPTIONS_MANDATORY=(ssid) - ;; - wim|wima|wimax) - OPTIONS_TYPE=wimax - OPTIONS_TYPED=(mac nsp) - ;; - g|gs|gsm) - OPTIONS_TYPE=gsm - OPTIONS_TYPED=(apn user password) - OPTIONS_MANDATORY=(apn) - ;; - c|cd|cdm|cdma) - OPTIONS_TYPE=cdma - OPTIONS_TYPED=(user password) - ;; - i|in|inf|infi|infin|infini|infinib|infiniba|infiniban|infiniband) - OPTIONS_TYPE=infiniband - OPTIONS_TYPED=(mac mtu transport-mode parent p-key) - ;; - bl|blu|blue|bluet|blueto|bluetoo|bluetoot|bluetooth) - OPTIONS_TYPE=bluetooth - OPTIONS_TYPED=(addr bt-type) - ;; - vl|vla|vlan) - OPTIONS_TYPE=vlan - OPTIONS_TYPED=(dev id flags ingress egress mtu) - OPTIONS_MANDATORY=(dev) - ;; - bond) - OPTIONS_TYPE=bond - OPTIONS_TYPED=(mode miimon downdelay updelay arp-interval arp-ip-target primary lacp-rate) - ;; - team) - OPTIONS_TYPE=team - OPTIONS_TYPED=(config) - ;; - bridge) - OPTIONS_TYPE=bridge - OPTIONS_TYPED=(stp priority forward-delay hello-time max-age ageing-time mac) - ;; - vp|vpn) - OPTIONS_TYPE=vpn - OPTIONS_TYPED=(vpn-type user) - OPTIONS_MANDATORY=(vpn-type) - ;; - 802-11-o|802-11-ol|802-11-olp|802-11-olpc|802-11-olpc-|802-11-olpc-m|802-11-olpc-me|802-11-olpc-mes|802-11-olpc-mesh| \ - o|ol|olp|olpc|olpc-|olpc-m|olpc-me|olpc-mes|olpc-mesh) - OPTIONS_TYPE=olpc-mesh - OPTIONS_TYPED=(ssid channel dhcp-anycast) - OPTIONS_MANDATORY=(ssid) - ;; - p|pp|ppp|pppo|pppoe) - OPTIONS_TYPE=pppoe - OPTIONS_TYPED=(username password service mtu mac) - OPTIONS_MANDATORY=(username) - ;; - a|ad|ads|adsl) - OPTIONS_TYPE=adsl - OPTIONS_TYPED=(username password protocol encapsulation) - OPTIONS_MANDATORY=(username protocol) - ;; - tu|tun) - OPTIONS_TYPE=tun - OPTIONS_TYPED=(mode owner group pi vnet-hdr multi-queue) - OPTIONS_MANDATORY=(mode) - ;; - ip|ip-|ip-t|ip-tu|ip-tun|ip-tunn|ip-tunne|ip-tunnel) - OPTIONS_TYPE=ip-tunnel - OPTIONS_TYPED=(mode remote local dev) - OPTIONS_MANDATORY=(mode remote) - ;; - m|ma|mac|macv|macvl|macvla|macvlan) - OPTIONS_TYPE=macvlan - OPTIONS_TYPED=(dev mode tap) - OPTIONS_MANDATORY=(dev mode) - ;; - vx|vxl|vxla|vxlan) - OPTIONS_TYPE=vxlan - OPTIONS_TYPED=(id remote local dev source-port-min source-port-max destination-port) - OPTIONS_MANDATORY=(id remote) - ;; - *) - # for an unknown connection type, we stop completion here - return 0 - ;; - esac - if [[ "$COMMAND_ARGS_WAIT_OPTIONS" -ne 1 ]]; then - # means, we are at the end of options. Nothing more to parse, just show - # what are the options now. - if [[ "${#OPTIONS_MANDATORY[@]}" -gt 0 ]]; then - _nmcli_list "$(echo "${OPTIONS[@]}") $(echo "${OPTIONS_TYPED[@]}")" - else - _nmcli_list "$(echo "${OPTIONS[@]}") $(echo "${OPTIONS_TYPED[@]}") $(echo "${OPTIONS_IP[@]}") $(echo "${OPTIONS_SEP[@]}")" - fi - return 0 - fi - if [[ "${#OPTIONS[@]}" -gt 0 ]]; then - # we still have some options from before, but no mandatory ones. Mix them with OPTIONS_TYPED - # and continue parsing the options... - OPTIONS=("${OPTIONS[@]}" "${OPTIONS_TYPED[@]}") - OPTIONS_NEXT_GROUP=("${OPTIONS_TYPED[@]}") - _nmcli_compl_ARGS && return 0 - - if [[ "$COMMAND_ARGS_WAIT_OPTIONS" -ne 1 ]]; then - # means, we are at the end of options. Nothing more to parse, just show - # what are the options now. - if [[ "${#OPTIONS_MANDATORY[@]}" -gt 0 ]]; then - _nmcli_list "$(echo "${OPTIONS[@]}")" - else - _nmcli_list "$(echo "${OPTIONS[@]}") $(echo "${OPTIONS_IP[@]}") $(echo "${OPTIONS_SEP[@]}")" - fi - return 0 - fi - - if [[ "$OPTIONS_UNKNOWN_OPTION" != "" ]]; then - # there was an unknown option specified. Maybe we have to stop with the completion. - if [[ "${#OPTIONS_MANDATORY[@]}" -gt 0 ]]; then - # we have an unknown option, but still mandatory ones that must be fullfiled first. - return 0 - fi - if ! (_nmcli_array_has_value OPTIONS_IP "${OPTIONS_UNKNOWN_OPTION:1}" || - _nmcli_array_has_value OPTIONS_SEP "${OPTIONS_UNKNOWN_OPTION:1}"); then - # the unknown option is neither an IP option nor a separator. - return 0 - fi - # The unknown option is an IP option or a separator, which is fine... continue... - fi - - fi - OPTIONS=("${OPTIONS_TYPED[@]}") - OPTIONS_NEXT_GROUP=() - - if [[ "${#OPTIONS_MANDATORY[@]}" -ge 1 ]]; then - # we have some mandatory options... don't check for IP options yet... - _nmcli_compl_ARGS && return 0 - - if _nmcli_array_has_value OPTIONS "${OPTIONS_MANDATORY[@]}"; then - _nmcli_list "$(echo "${OPTIONS[@]}")" - return 0 - fi - - if [[ "$OPTIONS_UNKNOWN_OPTION" != "" ]]; then - if ! (_nmcli_array_has_value OPTIONS_IP "${OPTIONS_UNKNOWN_OPTION:1}" || - _nmcli_array_has_value OPTIONS_SEP "${OPTIONS_UNKNOWN_OPTION:1}"); then - # the unknown option is neither an IP option nor a separator. - return 0 - fi - fi - fi - - - # no mandatory options... do final completion including IP options - OPTIONS=("${OPTIONS[@]}" "${OPTIONS_IP[@]}" "${OPTIONS_SEP[@]}") - OPTIONS_NEXT_GROUP=("${OPTIONS_IP[@]}" "${OPTIONS_SEP[@]}") - _nmcli_compl_ARGS && return 0 - - if [[ "$OPTIONS_UNKNOWN_OPTION" != "" ]]; then - return 0 - fi - - if [[ "$COMMAND_ARGS_WAIT_OPTIONS" -ne 1 ]]; then - # means, we are at the end of options. Nothing more to parse, just show - # what are the options now. - _nmcli_list "$(echo "${OPTIONS[@]}")" - return 0 - fi - - - # process the last group of options, as the OPTIONS_TYPED are already handled... - OPTIONS=("${OPTIONS_IP[@]}" "${OPTIONS_SEP[@]}") - OPTIONS_NEXT_GROUP=("${OPTIONS_SEP[@]}") - COMMAND_ARGS_WAIT_OPTIONS=0 - _nmcli_compl_ARGS && return 0 - - _nmcli_array_delete_at words 0 - _nmcli_compl_PROPERTIES type "$OPTIONS_TYPE" - - return 0 - + _nmcli_list_nl "$(nmcli --complete-args connection add "${words[@]}" 2>/dev/null)" fi ;; e|ed|edi|edit) @@ -1421,7 +1184,7 @@ _nmcli() ;; d|de|dev|devi|devic|device) if [[ ${#words[@]} -eq 2 ]]; then - _nmcli_compl_COMMAND "$command" status show connect reapply disconnect delete monitor wifi set lldp + _nmcli_compl_COMMAND "$command" status show connect reapply modify disconnect delete monitor wifi set lldp elif [[ ${#words[@]} -gt 2 ]]; then case "$command" in s|st|sta|stat|statu|status) @@ -1436,6 +1199,14 @@ _nmcli() _nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)" fi ;; + mod|modi|modif|modify) + if [[ ${#words[@]} -eq 3 ]]; then + _nmcli_compl_COMMAND_nl "${words[2]}" "$(nmcli --complete-args device modify "" 2>/dev/null)" + else + _nmcli_array_delete_at words 0 1 + _nmcli_list_nl "$(nmcli --complete-args device modify "${words[@]}" 2>/dev/null)" + fi + ;; d|di|dis|disc|disco|discon|disconn|disconne|disconnec|disconnect| \ de|del|dele|delet|delete| \ m|mo|mon|moni|monit|monito|monitor) |