* New completion function (nmcli) and patch for _ffmpeg
@ 2011-11-07 18:05 Haakon Riiser
2011-11-07 19:46 ` Sebastian Tramp
0 siblings, 1 reply; 3+ messages in thread
From: Haakon Riiser @ 2011-11-07 18:05 UTC (permalink / raw)
To: zsh-workers; +Cc: Peter.Stephenson
[-- Attachment #1: Type: text/plain, Size: 590 bytes --]
Here's a new completion function for nmcli, the command line interface
to Linux' Network Manager. I've tried to make it as complete as
possible. It has been tested on version 0.8.5.92 that comes with
Fedora 14. I have also tried to make it compatible with nmcli 0.9.0
and 0.9.1 (the latest version) by observing the differences in the man
page. The man pages were almost unchanged, so it should work across
all versions.
Also, I've attached a patch for the FFmpeg completion function.
Nothing major has changed, but there are a couple of fixes that are
worth pushing upstream.
--
Haakon
[-- Attachment #2: _ffmpeg.patch --]
[-- Type: text/x-patch, Size: 4571 bytes --]
Index: _ffmpeg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ffmpeg,v
retrieving revision 1.5
diff -u -1 -0 -r1.5 _ffmpeg
--- _ffmpeg 3 May 2011 18:38:56 -0000 1.5
+++ _ffmpeg 7 Nov 2011 17:27:29 -0000
@@ -14,20 +14,26 @@
acodecs=(copy ${${(M)${(f)"$(_call_program audio-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
_wanted ffmpeg-audio-codecs expl 'force audio codec (''copy'' to copy stream)' compadd -a acodecs
}
(( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() {
local vcodecs
vcodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
_wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs
}
+(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() {
+ local scodecs
+ scodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
+ _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a scodecs
+}
+
(( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() {
local formats
formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
_wanted ffmpeg-formats expl 'force format' compadd -a formats
}
(( $+functions[_ffmpeg_list_pix_fmts] )) || _ffmpeg_list_pix_fmts() {
echo - ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
}
@@ -77,20 +83,21 @@
fi
return $ret
}
(( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() {
if (( lastopt_takesargs )); then
lastopt+=":$lastopt_description:"
if (( $#lastopt_values )); then
if [[ $lastopt_type == flags ]]; then
+ lastopt="*$lastopt"
flagtype=${${lastopt%%:*}#-}
lastopt+="->$flagtype"
_ffmpeg_flags[$flagtype]="${lastopt_values[*]}"
else
lastopt+="(${lastopt_values[*]})"
fi
fi
fi
_ffmpeg_argspecs+=$lastopt
}
@@ -118,32 +125,38 @@
elif [[ $lastopt_description == [^[:space:]]##[[:space:]][[:space:]]* ]]; then
local example=${lastopt_description%% *}
example=${example//:/\\:}
lastopt_description=${lastopt_description##[^[:space:]]##[[:space:]]##}
lastopt_description=${lastopt_description//:/\\:}
if [[ $example == filename ]]; then
lastopt_takesargs=0
lastopt+=":$lastopt_description:_files"
elif [[ $lastopt == -[asv]pre ]]; then
lastopt_takesargs=0
+ lastopt="*$lastopt"
lastopt+=": :_ffmpeg_presets"
elif [[ $lastopt == -acodec ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_acodecs"
elif [[ $lastopt == -vcodec ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_vcodecs"
+ elif [[ $lastopt == -scodec ]]; then
+ lastopt_takesargs=0
+ lastopt+=": :_ffmpeg_scodecs"
elif [[ $lastopt == -f ]]; then
lastopt_takesargs=0
+ lastopt="*$lastopt"
lastopt+=": :_ffmpeg_formats"
elif [[ $lastopt == -pix_fmt ]]; then
lastopt_takesargs=0
+ lastopt="*$lastopt"
lastopt+=": :_ffmpeg_pix_fmts"
elif [[ $example == bitstream_filter ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_bsfs"
else
lastopt_takesargs=1
lastopt_description+=" ($example)"
fi
else
lastopt_takesargs=0
[-- Attachment #3: _nmcli --]
[-- Type: application/octet-stream, Size: 9131 bytes --]
#compdef nmcli
local context state line
typeset -A opt_args
local BOLD=$'\e[1m'
local NORM=$'\e[m'
if [[ -z $_nmcli_version ]]; then
_nmcli_version="${"$(nmcli --version)"##*version }"
fi
(( $+functions[_nmcli_is_running] )) || _nmcli_is_running() {
[[ $(nmcli -f running nm) != *'not running'* ]]
}
(( $+functions[_nmcli_con_ids] )) || _nmcli_con_ids() {
_nmcli_is_running || return
local -a con_ids
con_ids=(${(f)"$(nmcli -f name con)"})
con_ids=(${con_ids[2,-2]})
con_ids=(${con_ids[@]%%\ ##})
compadd -X "${BOLD}select connection${NORM}" -a con_ids
}
(( $+functions[_nmcli_con_uuids] )) || _nmcli_con_uuids() {
_nmcli_is_running || return
local -a con_uuids
con_uuids=(${(f)"$(nmcli -f uuid con)"})
con_uuids=(${con_uuids[2,-2]})
con_uuids=(${con_uuids[@]%%\ ##})
compadd -X "${BOLD}select connection${NORM}" -a con_uuids
}
(( $+functions[_nmcli_ifaces] )) || _nmcli_ifaces() {
local -a con_ifaces
con_ifaces=(${(f)"$(ifconfig -a)"})
con_ifaces=(${con_ifaces:# *})
con_ifaces=(${con_ifaces%% *})
compadd -X "${BOLD}select interface${NORM}" -a con_ifaces
}
(( $+functions[_nmcli_objects] )) || _nmcli_objects() {
local -a objects_array
objects_array=(
'nm:NetworkManager status'
'con:NetworkManager connections'
'dev:devices managed by NetworkManager'
)
_describe 'nmcli object' objects_array
}
(( $+functions[_nmcli_nm] )) || _nmcli_nm() {
local -a nm_array
nm_array=(
'status:show overall status of NetworkManager'
'enable:get status or enable/disable networking'
'sleep:get sleep status or put to sleep/awake NetworkManager'
'wifi:inquire or set status of WiFi in NetworkManager'
'wwan:inquire or set status of WWAN in NetworkManager'
)
_describe 'inquire and change state of NetworkManager' nm_array
}
(( $+functions[_nmcli_con] )) || _nmcli_con() {
local -a con_array
con_array=(
'list:list configured connections'
'status:print status of active connections'
'up:activate a connection'
'down:deactivate a connection'
)
if [[ $_nmcli_version == 0.9.[1-9]* ]]; then
con_array[5]="delete:delete a connection"
fi
_describe "get information about NetworkManager's connections" con_array
}
(( $+functions[_nmcli_con_list] )) || _nmcli_con_list() {
local -a con_list_array
con_list_array=(
'id:get details on connection specified by id'
'uuid:get details on connection specified by uuid'
)
if [[ $_nmcli_version == 0.8* ]]; then
con_list_array[3]='system:only list system connections'
con_list_array[4]='user:only list user connections'
fi
_describe 'list configured connections' con_list_array
}
(( $+functions[_nmcli_con_up] )) || _nmcli_con_up() {
local -a con_up_array
con_up_array=(
'id:activate connection specified by id'
'uuid:activate connection specified by uuid'
)
_describe 'activate connection by id or uuid' con_up_array
}
(( $+functions[_nmcli_con_down] )) || _nmcli_con_down() {
local -a con_down_array
con_down_array=(
'id:deactivate connection specified by id'
'uuid:deactivate connection specified by uuid'
)
_describe 'deactivate connection by id or uuid' con_down_array
}
(( $+functions[_nmcli_con_delete] )) || _nmcli_con_delete() {
local -a con_delete_array
con_delete_array=(
'id:delete connection specified by id'
'uuid:delete connection specified by uuid'
)
_describe 'delete connection by id or uuid' con_delete_array
}
(( $+functions[_nmcli_con_up_extraargs] )) || _nmcli_con_up_extraargs() {
local -a con_up_extraargs_array
con_up_extraargs_array=(
'iface:require a particular interface'
'ap:require a specific access point'
'--nowait:don''t wait for command completion'
'--timeout:specify how long to wait for operation to complete'
)
_describe 'extra options for "con up"' con_up_extraargs_array
}
(( $+functions[_nmcli_dev_disconnect_extraargs] )) || _nmcli_dev_disconnect_extraargs() {
local -a dev_disconnect_extraargs_array
dev_disconnect_extraargs_array=(
'--nowait:don''t wait for command completion'
'--timeout:specify how long to wait for operation to complete'
)
_describe 'extra options for "dev disconnect"' dev_disconnect_extraargs_array
}
(( $+functions[_nmcli_dev_wifi_list] )) || _nmcli_dev_wifi_list() {
local -a dev_wifi_list_array
dev_wifi_list_array=(
'iface:list APs for a particular interface'
)
if [[ $_nmcli_version == 0.8* || $_nmcli_version == 0.9.0* ]]; then
dev_wifi_list_array[2] = 'hwaddr:list a specific AP by MAC address'
elif [[ $_nmcli_version == 0.9.[1-9]* ]]; then
dev_wifi_list_array[2] = 'bssid:list a specific AP by BSSID'
fi
_describe 'options for specifying the AP to list' dev_wifi_list_array
}
(( $+functions[_nmcli_dev] )) || _nmcli_dev() {
local -a dev_array
dev_array=(
'status:print status of devices'
'list:get detailed information about devices'
'disconnect:disconnect device and prevent it from automatically activating'
'wifi:list available WiFi access points'
)
_describe "get information about devices" dev_array
}
(( $+functions[_nmcli_truefalse] )) || _nmcli_truefalse() {
compadd -X "${BOLD}use true/false to modify (nothing = query status)${NORM}" true false
}
(( $+functions[_nmcli_onoff] )) || _nmcli_onoff() {
compadd -X "${BOLD}use on/off to modify (nothing = query status)${NORM}" on off
}
local w1="${words[$#words - 1]}"
local w2="${words[$#words - 2]}"
local w3="${words[$#words - 3]}"
local w4="${words[$#words - 4]}"
if [[ $w2 == nm && $w1 == (sleep|enable) ]]; then
_nmcli_truefalse && return
elif [[ $w2 == nm && $w1 == (wifi|wwan) ]]; then
_nmcli_onoff && return
elif [[ $w1 == nm ]]; then
_nmcli_nm && return
elif [[ $w3 == con && $w2 == list && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $w3 == con && $w2 == list && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ $w2 == con && $w1 == list ]]; then
_nmcli_con_list && return
elif [[ $w3 == con && $w2 == (up|down) && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w3 == con && $w2 == delete && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $w3 == con && $w2 == (up|down) && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w3 == con && $w2 == delete && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ ${(pj:\0:)words} == *$'\0con\0up\0'(id|uuid)$'\0'* ]]; then
if [[ $w1 == iface ]]; then
_nmcli_ifaces && return
elif [[ $w1 == ap ]]; then
compadd -x "${BOLD}enter MAC address${NORM}" && return
elif [[ $w1 == --timeout ]]; then
compadd -x "${BOLD}enter timeout${NORM}" && return
else
_nmcli_con_up_extraargs && return
fi
elif [[ $w2 == con && $w1 == up ]]; then
_nmcli_con_up && return
elif [[ $w2 == con && $w1 == down ]]; then
_nmcli_con_down && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w2 == con && $w1 == delete ]]; then
_nmcli_con_delete && return
elif [[ $w1 == con ]]; then
_nmcli_con && return
elif [[ $w3 == dev && $w2 == (list|disconnect) && $w1 == iface ]]; then
_nmcli_ifaces && return
elif [[ ${(pj:\0:)words} == *$'\0dev\0disconnect\0iface\0'* ]]; then
if [[ $w1 == --timeout ]]; then
compadd -x "${BOLD}enter timeout${NORM}" && return
else
_nmcli_dev_disconnect_extraargs && return
fi
elif [[ $w2 == dev && $w1 == list ]]; then
compadd iface && return
elif [[ $w2 == dev && $w1 == disconnect ]]; then
compadd iface && return
elif [[ $w4 == dev && $w3 == wifi && $w2 == list && $w1 == iface ]]; then
_nmcli_ifaces && return
elif [[ $w4 == dev && $w3 == wifi && $w2 == list && $w1 == hwaddr ]]; then
compadd -x "${BOLD}enter MAC address${NORM}" && return
elif [[ $w3 == dev && $w2 == wifi && $w1 == list ]]; then
_nmcli_dev_wifi_list && return
elif [[ $w2 == dev && $w1 == wifi ]]; then
compadd list && return
elif [[ $w1 == dev ]]; then
_nmcli_dev && return
else
_arguments \
{'(--terse)-t','(-t)--terse'}'[terse output]' \
{'(--pretty)-p','(-p)--pretty'}'[pretty output]' \
{'(--mode)-m','(-m)--mode'}'[output mode]:output mode:(tabular multiline)' \
{'(--fields)-f','(-f)--fields'}'[specify fields to output]: :->fields' \
{'(--escape)-e','(-e)--escape'}'[escape columns separators in values]:escape columns separators in values:(yes no)' \
{'(--version)-v','(-v)--version'}'[show program version]' \
{'(--help)-h','(-h)--help'}'[print this help]' \
'*::nmcli object:_nmcli_objects' \
&& return
fi
[[ "$state" == "fields" ]] &&
_values -s , 'fields to be printed' \
all common \
autoconnect dbus-path device name net-enabled readonly running \
scope state timestamp timestamp-real type uuid wifi wifi-hardware \
wwan wwan-hardware \
&& return
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: New completion function (nmcli) and patch for _ffmpeg
2011-11-07 18:05 New completion function (nmcli) and patch for _ffmpeg Haakon Riiser
@ 2011-11-07 19:46 ` Sebastian Tramp
2011-11-07 21:35 ` Haakon Riiser
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Tramp @ 2011-11-07 19:46 UTC (permalink / raw)
To: Haakon Riiser; +Cc: zsh-workers, Peter.Stephenson
On Mon, Nov 07, 2011 at 07:05:36PM +0100, Haakon Riiser wrote:
> Here's a new completion function for nmcli, the command line interface
> to Linux' Network Manager. I've tried to make it as complete as
> possible. It has been tested on version 0.8.5.92 that comes with
> Fedora 14. I have also tried to make it compatible with nmcli 0.9.0
> and 0.9.1 (the latest version) by observing the differences in the man
> page. The man pages were almost unchanged, so it should work across
> all versions.
Haakon,
+1 - like it very much.
Tested with an older 0.8.3.998 and works smooth!
thank you
Seebi
--
WebID: http://sebastian.tramp.name
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: New completion function (nmcli) and patch for _ffmpeg
2011-11-07 19:46 ` Sebastian Tramp
@ 2011-11-07 21:35 ` Haakon Riiser
0 siblings, 0 replies; 3+ messages in thread
From: Haakon Riiser @ 2011-11-07 21:35 UTC (permalink / raw)
To: Haakon Riiser, zsh-workers, Peter.Stephenson
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]
On Mon, Nov 7, 2011 at 20:46, Sebastian Tramp
<tramp@informatik.uni-leipzig.de> wrote:
> On Mon, Nov 07, 2011 at 07:05:36PM +0100, Haakon Riiser wrote:
>
>> Here's a new completion function for nmcli, the command line interface
>> to Linux' Network Manager. [...]
>
> Haakon,
>
> +1 - like it very much.
> Tested with an older 0.8.3.998 and works smooth!
>
> thank you
Glad to hear it was immediately useful to someone. :)
Anyway, I have an updated version already. There are no changes to the
completion itself, I've only tried to make it more portable and in
line with other completion functions:
* Use _call_program so that users can override the calls
* Use _describe, _wanted and _message instead of compadd directly (to
avoid using ANSI escape codes to set the bold attribute in the
description line)
* Use _net_interfaces to generate completion for network interfaces
* Fixed some weird indenting
That's it for now.
--
Haakon
[-- Attachment #2: _nmcli --]
[-- Type: application/octet-stream, Size: 8973 bytes --]
#compdef nmcli
local context state line expl
typeset -A opt_args
if [[ -z $_nmcli_version ]]; then
_nmcli_version="${"$(_call_program nmcli $words[1] --version)"##*version }"
fi
(( $+functions[_nmcli_is_running] )) || _nmcli_is_running() {
[[ $(_call_program nmcli $words[1] -f running nm) != *'not running'* ]]
}
(( $+functions[_nmcli_con_ids] )) || _nmcli_con_ids() {
_nmcli_is_running || return
local -a con_ids
con_ids=(${(f)"$(_call_program nmcli $words[1] -f name con)"})
con_ids=(${con_ids[2,-2]})
con_ids=(${con_ids[@]%%\ ##})
_describe 'select connection' con_ids
}
(( $+functions[_nmcli_con_uuids] )) || _nmcli_con_uuids() {
_nmcli_is_running || return
local -a con_uuids
con_uuids=(${(f)"$(_call_program nmcli $words[1] -f uuid con)"})
con_uuids=(${con_uuids[2,-2]})
con_uuids=(${con_uuids[@]%%\ ##})
_describe 'select connection' con_uuids
}
(( $+functions[_nmcli_objects] )) || _nmcli_objects() {
local -a objects_array
objects_array=(
'nm:NetworkManager status'
'con:NetworkManager connections'
'dev:devices managed by NetworkManager'
)
_describe 'nmcli object' objects_array
}
(( $+functions[_nmcli_nm] )) || _nmcli_nm() {
local -a nm_array
nm_array=(
'status:show overall status of NetworkManager'
'enable:get status or enable/disable networking'
'sleep:get sleep status or put to sleep/awake NetworkManager'
'wifi:inquire or set status of WiFi in NetworkManager'
'wwan:inquire or set status of WWAN in NetworkManager'
)
_describe 'inquire and change state of NetworkManager' nm_array
}
(( $+functions[_nmcli_con] )) || _nmcli_con() {
local -a con_array
con_array=(
'list:list configured connections'
'status:print status of active connections'
'up:activate a connection'
'down:deactivate a connection'
)
if [[ $_nmcli_version == 0.9.[1-9]* ]]; then
con_array[5]="delete:delete a connection"
fi
_describe "get information about NetworkManager's connections" con_array
}
(( $+functions[_nmcli_con_list] )) || _nmcli_con_list() {
local -a con_list_array
con_list_array=(
'id:get details on connection specified by id'
'uuid:get details on connection specified by uuid'
)
if [[ $_nmcli_version == 0.8* ]]; then
con_list_array[3]='system:only list system connections'
con_list_array[4]='user:only list user connections'
fi
_describe 'list configured connections' con_list_array
}
(( $+functions[_nmcli_con_up] )) || _nmcli_con_up() {
local -a con_up_array
con_up_array=(
'id:activate connection specified by id'
'uuid:activate connection specified by uuid'
)
_describe 'activate connection by id or uuid' con_up_array
}
(( $+functions[_nmcli_con_down] )) || _nmcli_con_down() {
local -a con_down_array
con_down_array=(
'id:deactivate connection specified by id'
'uuid:deactivate connection specified by uuid'
)
_describe 'deactivate connection by id or uuid' con_down_array
}
(( $+functions[_nmcli_con_delete] )) || _nmcli_con_delete() {
local -a con_delete_array
con_delete_array=(
'id:delete connection specified by id'
'uuid:delete connection specified by uuid'
)
_describe 'delete connection by id or uuid' con_delete_array
}
(( $+functions[_nmcli_con_up_extraargs] )) || _nmcli_con_up_extraargs() {
local -a con_up_extraargs_array
con_up_extraargs_array=(
'iface:require a particular interface'
'ap:require a specific access point'
'--nowait:don''t wait for command completion'
'--timeout:specify how long to wait for operation to complete'
)
_describe 'extra options for "con up"' con_up_extraargs_array
}
(( $+functions[_nmcli_dev_disconnect_extraargs] )) || _nmcli_dev_disconnect_extraargs() {
local -a dev_disconnect_extraargs_array
dev_disconnect_extraargs_array=(
'--nowait:don''t wait for command completion'
'--timeout:specify how long to wait for operation to complete'
)
_describe 'extra options for "dev disconnect"' dev_disconnect_extraargs_array
}
(( $+functions[_nmcli_dev_wifi_list] )) || _nmcli_dev_wifi_list() {
local -a dev_wifi_list_array
dev_wifi_list_array=(
'iface:list APs for a particular interface'
)
if [[ $_nmcli_version == 0.8* || $_nmcli_version == 0.9.0* ]]; then
dev_wifi_list_array[2] = 'hwaddr:list a specific AP by MAC address'
elif [[ $_nmcli_version == 0.9.[1-9]* ]]; then
dev_wifi_list_array[2] = 'bssid:list a specific AP by BSSID'
fi
_describe 'options for specifying the AP to list' dev_wifi_list_array
}
(( $+functions[_nmcli_dev] )) || _nmcli_dev() {
local -a dev_array
dev_array=(
'status:print status of devices'
'list:get detailed information about devices'
'disconnect:disconnect device and prevent it from automatically activating'
'wifi:list available WiFi access points'
)
_describe "get information about devices" dev_array
}
(( $+functions[_nmcli_truefalse] )) || _nmcli_truefalse() {
_wanted boolean expl 'use true/false to modify (nothing = query status)' compadd true false
}
(( $+functions[_nmcli_onoff] )) || _nmcli_onoff() {
_wanted onoff expl 'use on/off to modify (nothing = query status)' compadd on off
}
local w1="${words[$#words - 1]}"
local w2="${words[$#words - 2]}"
local w3="${words[$#words - 3]}"
local w4="${words[$#words - 4]}"
if [[ $w2 == nm && $w1 == (sleep|enable) ]]; then
_nmcli_truefalse && return
elif [[ $w2 == nm && $w1 == (wifi|wwan) ]]; then
_nmcli_onoff && return
elif [[ $w1 == nm ]]; then
_nmcli_nm && return
elif [[ $w3 == con && $w2 == list && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $w3 == con && $w2 == list && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ $w2 == con && $w1 == list ]]; then
_nmcli_con_list && return
elif [[ $w3 == con && $w2 == (up|down) && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w3 == con && $w2 == delete && $w1 == id ]]; then
_nmcli_con_ids && return
elif [[ $w3 == con && $w2 == (up|down) && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w3 == con && $w2 == delete && $w1 == uuid ]]; then
_nmcli_con_uuids && return
elif [[ ${(pj:\0:)words} == *$'\0con\0up\0'(id|uuid)$'\0'* ]]; then
if [[ $w1 == iface ]]; then
_net_interfaces && return
elif [[ $w1 == ap ]]; then
_message -e descriptions 'enter MAC address' && return
elif [[ $w1 == --timeout ]]; then
_message -e descriptions 'enter timeout' && return
else
_nmcli_con_up_extraargs && return
fi
elif [[ $w2 == con && $w1 == up ]]; then
_nmcli_con_up && return
elif [[ $w2 == con && $w1 == down ]]; then
_nmcli_con_down && return
elif [[ $_nmcli_version == 0.9.[1-9]* && $w2 == con && $w1 == delete ]]; then
_nmcli_con_delete && return
elif [[ $w1 == con ]]; then
_nmcli_con && return
elif [[ $w3 == dev && $w2 == (list|disconnect) && $w1 == iface ]]; then
_net_interfaces && return
elif [[ ${(pj:\0:)words} == *$'\0dev\0disconnect\0iface\0'* ]]; then
if [[ $w1 == --timeout ]]; then
_message -e descriptions 'enter timeout' && return
else
_nmcli_dev_disconnect_extraargs && return
fi
elif [[ $w2 == dev && $w1 == list ]]; then
compadd iface && return
elif [[ $w2 == dev && $w1 == disconnect ]]; then
compadd iface && return
elif [[ $w4 == dev && $w3 == wifi && $w2 == list && $w1 == iface ]]; then
_net_interfaces && return
elif [[ $w4 == dev && $w3 == wifi && $w2 == list && $w1 == hwaddr ]]; then
_message -e descriptions 'enter MAC address' && return
elif [[ $w3 == dev && $w2 == wifi && $w1 == list ]]; then
_nmcli_dev_wifi_list && return
elif [[ $w2 == dev && $w1 == wifi ]]; then
compadd list && return
elif [[ $w1 == dev ]]; then
_nmcli_dev && return
else
_arguments \
{'(--terse)-t','(-t)--terse'}'[terse output]' \
{'(--pretty)-p','(-p)--pretty'}'[pretty output]' \
{'(--mode)-m','(-m)--mode'}'[output mode]:output mode:(tabular multiline)' \
{'(--fields)-f','(-f)--fields'}'[specify fields to output]: :->fields' \
{'(--escape)-e','(-e)--escape'}'[escape columns separators in values]:escape columns separators in values:(yes no)' \
{'(--version)-v','(-v)--version'}'[show program version]' \
{'(--help)-h','(-h)--help'}'[print this help]' \
'*::nmcli object:_nmcli_objects' \
&& return
fi
[[ "$state" == "fields" ]] &&
_values -s , 'fields to be printed' \
all common \
autoconnect dbus-path device name net-enabled readonly running \
scope state timestamp timestamp-real type uuid wifi wifi-hardware \
wwan wwan-hardware \
&& return
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-07 21:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07 18:05 New completion function (nmcli) and patch for _ffmpeg Haakon Riiser
2011-11-07 19:46 ` Sebastian Tramp
2011-11-07 21:35 ` Haakon Riiser
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).