summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-04-03 17:00:48 +0200
committerJiří Klimeš <jklimes@redhat.com>2013-04-09 10:31:13 +0200
commit654a79ba8899841b5a0722c0b67b32615bc5663a (patch)
treed5435ff59102d22d5f8410dbc7821a5aa26d1f03
parentc84315fd12772a5a6c1aebcad4d7b829da4cf1f6 (diff)
downloadNetworkManager-654a79ba8899841b5a0722c0b67b32615bc5663a.tar.gz
cli: update bash completion file for the new syntax
-rw-r--r--cli/completion/nmcli169
1 files changed, 116 insertions, 53 deletions
diff --git a/cli/completion/nmcli b/cli/completion/nmcli
index 7bd9431a3c..93e54735c3 100644
--- a/cli/completion/nmcli
+++ b/cli/completion/nmcli
@@ -1,5 +1,5 @@
-# nmcli completion -*- shell-script -*-
-# Based on
+# nmcli(1) completion -*- shell-script -*-
+# Originally based on
# https://github.com/GArik/bash-completion/blob/master/completions/nmcli
_nmcli_list()
@@ -10,12 +10,22 @@ _nmcli_list()
_nmcli_con_id()
{
local IFS=$'\n'
- COMPREPLY=( $( compgen -W "$(nmcli -t -f NAME con list 2>/dev/null )" -- $cur ) )
+ COMPREPLY=( $( compgen -W "$(nmcli -t -f NAME con show c 2>/dev/null )" -- $cur ) )
}
_nmcli_con_uuid()
{
- COMPREPLY=( $( compgen -W "$(nmcli -t -f UUID con list 2>/dev/null )" -- $cur ) )
+ COMPREPLY=( $( compgen -W "$(nmcli -t -f UUID con show c 2>/dev/null )" -- $cur ) )
+}
+
+_nmcli_con_path()
+{
+ COMPREPLY=( $( compgen -W "$(nmcli -t -f DBUS-PATH con show c 2>/dev/null )" -- $cur ) )
+}
+
+_nmcli_con_apath()
+{
+ COMPREPLY=( $( compgen -W "$(nmcli -t -f DBUS-PATH con show a 2>/dev/null )" -- $cur ) )
}
_nmcli_ap_ssid()
@@ -29,6 +39,11 @@ _nmcli_ab_bssid()
COMPREPLY=( $( compgen -W "$(nmcli -t -f BSSID dev wifi list 2>/dev/null )" -- $cur ) )
}
+_nmcli_NM_devices()
+{
+ COMPREPLY=( $( compgen -W "$(nmcli -t -f DEVICE dev status 2>/dev/null )" -- $cur ) )
+}
+
_nmcli()
{
local cur prev words cword
@@ -36,11 +51,11 @@ _nmcli()
case $prev in
-m|--mode)
- COMPREPLY=( $( compgen -W 'tabular multiline' -- $cur ) )
+ _nmcli_list "tabular multiline"
return 0
;;
-f|--fields)
- COMPREPLY=( $( compgen -W 'all common' -- $cur ) )
+ _nmcli_list "all common"
return 0
;;
-e|--escape)
@@ -55,8 +70,17 @@ _nmcli()
_nmcli_con_uuid
return 0
;;
+ path)
+ _nmcli_con_path
+ return 0
+ ;;
+ apath)
+ _nmcli_con_apath
+ return 0
+ ;;
iface)
- _available_interfaces
+ #_available_interfaces
+ _nmcli_NM_devices
return 0
;;
bssid)
@@ -71,84 +95,106 @@ _nmcli()
if [[ $cword -eq 1 ]] ; then
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '--terse --pretty --mode --fields \
- --escape --version --help' -- $cur ) )
+ if [[ "$cur" == -[tpmfenavh] ]]; then
+ _nmcli_list "-t -p -m -f -e -n -a -v -h"
+ else
+ _nmcli_list "--terse --pretty --mode --fields --escape --nocheck --ask --version --help"
+ fi
else
- COMPREPLY=( $( compgen -W "nm con dev" -- $cur ) )
+ _nmcli_list "general networking radio connection device"
fi
else
local object=${words[1]}
local command=${words[2]}
+ [[ $command == help ]] && return 0
+
case $object in
- nm)
+ general)
case $command in
- enable)
- _nmcli_list "true false"
+ status | permissions)
return 0
;;
- sleep)
- _nmcli_list "true false"
+ logging)
+ _nmcli_list "level domains"
return 0
;;
- wifi)
- _nmcli_list "on off"
- return 0
- ;;
- wwan)
- _nmcli_list "on off"
- return 0
- ;;
- wimax)
+ esac
+
+ _nmcli_list "status permissions logging help"
+ ;;
+
+ networking)
+ case $command in
+ on | off)
+ return 0
+ ;;
+ esac
+ _nmcli_list "on off help"
+ ;;
+
+ radio)
+ case $command in
+ all | wifi | mobile | wimax)
_nmcli_list "on off"
return 0
;;
esac
- COMPREPLY=( $( compgen -W 'status permissions enable sleep \
- wifi wwan wimax' -- $cur ) )
+ _nmcli_list "all wifi mobile wimax help"
;;
- con)
+
+ connection)
case $command in
- list)
- COMPREPLY=( $( compgen -W 'id uuid' -- $cur ) )
+ show)
+ local subcommand=${words[3]}
+
+ case $subcommand in
+ configured)
+ _nmcli_list "id uuid path"
+ return 0
+ ;;
+ active)
+ _nmcli_list "id uuid path apath"
+ return 0
+ ;;
+ esac
+
+ _nmcli_list "configured active"
return 0
;;
up)
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '--nowait --timeout' \
- -- $cur ) )
+ _nmcli_list "--nowait --timeout"
else
- COMPREPLY=( $( compgen -W 'id uuid iface ap nsp' \
- -- $cur ) )
+ _nmcli_list "id uuid path iface ap nsp"
fi
return 0
;;
down)
- COMPREPLY=( $( compgen -W 'id uuid' -- $cur ) )
+ _nmcli_list "id uuid path apath"
return 0
;;
delete)
- COMPREPLY=( $( compgen -W 'id uuid' -- $cur ) )
+ _nmcli_list "id uuid path"
return 0
;;
esac
- COMPREPLY=( $( compgen -W 'list status up down delete' \
- -- $cur ) )
+ _nmcli_list "show up down delete help"
;;
- dev)
+
+ device)
case $command in
- list)
- COMPREPLY=( $( compgen -W 'iface' -- $cur ) )
+ show)
+ _nmcli_NM_devices
return 0
;;
disconnect)
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '--nowait --timeout' \
- -- $cur ) )
+ _nmcli_list "--nowait --timeout"
else
- COMPREPLY=( $( compgen -W 'iface' -- $cur ) )
+ _nmcli_NM_devices
fi
return 0
;;
@@ -157,34 +203,51 @@ _nmcli()
case $subcommand in
list)
- COMPREPLY=( $( compgen -W 'iface bssid' \
- -- $cur ) )
+ _nmcli_list "iface bssid"
return 0
;;
connect)
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '--private \
- --nowait --timeout' -- $cur ) )
+ _nmcli_list "--private --nowait --timeout"
else
if [[ "$prev" == "connect" ]]; then
_nmcli_ap_ssid
else
- COMPREPLY=( $( compgen -W 'password \
- wep-key-type iface bssid name' \
- -- $cur ) )
+ _nmcli_list "password wep-key-type iface bssid name"
fi
fi
return 0
;;
+ scan)
+ if [[ "$cur" == i* ]]; then
+ _nmcli_list "iface"
+ else
+ _nmcli_NM_devices
+ fi
+ return 0
+ ;;
+ esac
+
+ _nmcli_list "list connect scan"
+ return 0
+ ;;
+ wimax)
+ local subcommand=${words[3]}
+
+ case $subcommand in
+ list)
+ _nmcli_list "iface nsp"
+ return 0
+ ;;
esac
- COMPREPLY=( $( compgen -W 'list connect' -- $cur ) )
+ _nmcli_list "list"
return 0
;;
+
esac
- COMPREPLY=( $( compgen -W 'status list disconnect wifi' \
- -- $cur ) )
+ _nmcli_list "status show disconnect wifi wimax help"
;;
esac