1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 09:41:44 +02:00

Danek: 30562: Solaris completion updates

This commit is contained in:
Peter Stephenson 2012-07-08 17:54:01 +00:00
parent e1491b2542
commit b2722856e2
8 changed files with 134 additions and 33 deletions

View file

@ -1,3 +1,12 @@
2012-07-08 Peter Stephenson <p.w.stephenson@ntlworld.com>
* Danek: 30562: Completion/Solaris/Command/_dladm,
Completion/Solaris/Command/_flowadm,
Completion/Solaris/Command/_ipadm,
Completion/Solaris/Command/_zoneadm,
Completion/Unix/Command/_zfs, Completion/Unix/Command/_zpool,
Completion/Unix/Type/_zfs_dataset: Solaris completion updates.
2012-06-30 Barton E. Schaefer <schaefer@zsh.org> 2012-06-30 Barton E. Schaefer <schaefer@zsh.org>
* 30540: Src/builtin.c: process the rest of the typeset flags when * 30540: Src/builtin.c: process the rest of the typeset flags when
@ -16433,5 +16442,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5677 $ * $Revision: 1.5678 $
***************************************************** *****************************************************

View file

@ -1,5 +1,5 @@
#compdef dladm #compdef dladm
# Synced with the S11U1 build 16 man page # Synced with the S11U1 build 19 man page
_dladm_links() { _dladm_links() {
compadd "$@" - $(dladm show-link -p -o link) compadd "$@" - $(dladm show-link -p -o link)
@ -81,15 +81,15 @@ _dladm() {
# TODO: some subcommands may take different arguments based on options # TODO: some subcommands may take different arguments based on options
subcmds=( subcmds=(
"show-ether" "show-ib" "show-usage" "help" "show-ether" "show-ib" "show-usage"
{"rename","show"}"-link" {"rename","show"}"-link"
{"add","create","delete","modify","remove","show"}"-aggr" {"add","create","delete","modify","remove","show"}"-aggr"
{"connect","disconnect","scan","show"}"-wifi" {"connect","disconnect","scan","show"}"-wifi"
{"reset","set","show"}"-linkprop" {"reset","set","show"}"-linkprop"
{"create","delete","show"}"-secobj" {"create","delete","show"}"-secobj"
{"create","delete","show"}"-vlan" {"create","delete","modify","show"}"-vlan"
{"delete","show"}"-phys" {"delete","show"}"-phys"
{"create","delete","show"}"-vnic" {"create","delete","modify","show"}"-vnic"
{"create","delete","show"}"-etherstub" {"create","delete","show"}"-etherstub"
{"create","modify","delete","add","remove","show"}"-bridge" {"create","modify","delete","add","remove","show"}"-bridge"
{"create","modify","delete","show"}"-iptun" {"create","modify","delete","show"}"-iptun"
@ -112,7 +112,7 @@ _dladm() {
link_properties=( "link" "zone" "class" "mtu" "state" "over" ) link_properties=( "link" "zone" "class" "mtu" "state" "over" )
link_stats_properties=( "link" "ipackets" "rbytes" "ierrors" "opackets" "obytes" "oerrors" ) link_stats_properties=( "link" "ipackets" "rbytes" "ierrors" "opackets" "obytes" "oerrors" )
aggr_properties=( "link" "policy" "addrpolicy" "lacpactivity" "lacptimer" "flags" ) aggr_properties=( "link" "policy" "addrpolicy" "lacpactivity" "lacptimer" "mode" "flags" )
aggr_lacp_properties=( "link" "port" "aggregatable" "sync" "coll" "dist" "defaulted" "expired" ) aggr_lacp_properties=( "link" "port" "aggregatable" "sync" "coll" "dist" "defaulted" "expired" )
aggr_ext_properties=( "link" "port" "speed" "duplex" "state" "address" "portstate" ) aggr_ext_properties=( "link" "port" "speed" "duplex" "state" "address" "portstate" )
@ -148,8 +148,15 @@ _dladm() {
linkprops_general=( linkprops_general=(
"autopush:streams modules:" "autopush:streams modules:"
"cos:value:(0 1 2 3 4 5 6 7)"
"cpus:processors:" "cpus:processors:"
"cpus-effective" "cpus-effective"
"etsbw-lcl:percentage:"
"etsbw-lcl-advice"
"etsbw-lcl-effective"
"etsbw-rmt-effective"
"lro:value:(off on auto)"
"lro-effective"
"mac-address:MAC address:" "mac-address:MAC address:"
"maxbw:bandwith:" "maxbw:bandwith:"
"pool:pools:" "pool:pools:"
@ -216,6 +223,8 @@ _dladm() {
"mtu:value:" "mtu:value:"
"ntcs" "ntcs"
"pfcmap:value:" "pfcmap:value:"
"pfcmap-lcl-effective"
"pfcmap-rmt-effective"
"speed" "speed"
"tagmode:value:(normal vlanonly)" "tagmode:value:(normal vlanonly)"
"vlan-announce:value:(off gvrp)" "vlan-announce:value:(off gvrp)"
@ -233,6 +242,10 @@ _dladm() {
) )
case $service in case $service in
("help")
_arguments ':subcommand:($subcmds)'
;;
("show-link") ("show-link")
_arguments -A "-*" \ _arguments -A "-*" \
'(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \ '(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \
@ -257,6 +270,7 @@ _dladm() {
("show-phys") ("show-phys")
_arguments -A "-*" \ _arguments -A "-*" \
'-D[Show Data Center Bridging information]:featureset:(ets pfc)' \
'-H[Show hardware resource usage]' \ '-H[Show hardware resource usage]' \
'-L[Display location information]' \ '-L[Display location information]' \
'(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \ '(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \
@ -280,6 +294,7 @@ _dladm() {
'(-t --temporary)'{-t,--temporary}'[Aggregation should be temporary]' \ '(-t --temporary)'{-t,--temporary}'[Aggregation should be temporary]' \
'(-R --root)'{-R,--root}'[Root directory]:directory:_path_files -/' \ '(-R --root)'{-R,--root}'[Root directory]:directory:_path_files -/' \
'(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \ '(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \
'(-m --mode)'{-m,--mode}'[Aggregation mode]:mode:(dlmp trunk)' \
'(-P --policy)'{-P,--policy}'[Port selection policy]:policy:_values -s , "policy" L2 L3 L4' \ '(-P --policy)'{-P,--policy}'[Port selection policy]:policy:_values -s , "policy" L2 L3 L4' \
'(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \ '(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \
'(-T --lacp-timer)'{-T,--lacp-timer}'[LACP timer]:lacp timer:(short long)' \ '(-T --lacp-timer)'{-T,--lacp-timer}'[LACP timer]:lacp timer:(short long)' \
@ -292,6 +307,7 @@ _dladm() {
'(-t --temporary)'{-t,--temporary}'[Aggregation should be temporary]' \ '(-t --temporary)'{-t,--temporary}'[Aggregation should be temporary]' \
'(-R --root)'{-R,--root}'[Root directory]:directory:_path_files -/' \ '(-R --root)'{-R,--root}'[Root directory]:directory:_path_files -/' \
'(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \ '(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \
'(-m --mode)'{-m,--mode}'[Aggregation mode]:mode:(dlmp trunk)' \
'(-P --policy)'{-P,--policy}'[Port selection policy]:policy:_values -s , "policy" L2 L3 L4' \ '(-P --policy)'{-P,--policy}'[Port selection policy]:policy:_values -s , "policy" L2 L3 L4' \
'(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \ '(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \
'(-T --lacp-timer)'{-T,--lacp-timer}'[LACP timer]:lacp timer:(short long)' \ '(-T --lacp-timer)'{-T,--lacp-timer}'[LACP timer]:lacp timer:(short long)' \
@ -358,6 +374,19 @@ _dladm() {
':VLAN link name:_dladm_vlans' ':VLAN link name:_dladm_vlans'
;; ;;
("modify-vlan")
_arguments -A "-*" \
'(-t --temporary)'{-t,--temporary}'[VLAN should be temporary]' \
'(-f --force)'{-f,--force}'[Force VLAN creation]' \
'(-R --root-dir)'{-R,--root-dir}'[Root directory]:directory:_path_files -/' \
'(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \
'-v[VLAN ID]:id:' \
- set1 \
'-L[Source link]:link:_dladm_links' \
- set2 \
':VLAN link name:'
;;
("show-vlan") ("show-vlan")
_arguments -A "-*" \ _arguments -A "-*" \
'(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \ '(-P --persistent)'{-P,--persistent}'[Display persistent link configuration]' \
@ -486,6 +515,21 @@ _dladm() {
':VNIC name:_dladm_vnics' ':VNIC name:_dladm_vnics'
;; ;;
("modify-vnic")
# TODO: MAC address completion could be richer
_arguments -A "-*" \
'(-t --temporary)'{-t,--temporary}'[Creation should be temporary]' \
'(-R --root)'{-R,--root}'[Root directory]:directory:_path_files -/' \
'(-l --link)'{-l,--link}'[Component link]:link:_dladm_links' \
'(-m --mac-address)'{-m,--mac-address}'[MAC address]:address:(factory random auto vrrp)' \
'-v[VLAN ID]:id:' \
'(-p --prop)'{-p,--prop}'[Property values]:value:_values -s , "property" ${(M)linkprops_general\:#*\:*}' \
- set1 \
'-L[Source link]:link:_dladm_links' \
- set2 \
':VNIC name:'
;;
("show-vnic") ("show-vnic")
_arguments -A "-*" \ _arguments -A "-*" \
'(-P --persistent)'{-P,--persistent}'[Display persistent object information]' \ '(-P --persistent)'{-P,--persistent}'[Display persistent object information]' \

View file

@ -1,5 +1,5 @@
#compdef flowadm #compdef flowadm
# Synced with the Nevada build 171 man page # Synced with the S11U1 build 19 man page
_flowadm() { _flowadm() {
@ -16,6 +16,7 @@ _flowadm_flow_int(){
} }
subcmds=( subcmds=(
"help"
"show-flow" "show-flow"
"add-flow" "add-flow"
"remove-flow" "remove-flow"
@ -49,6 +50,10 @@ if [[ $service == "flowadm" ]]; then
fi fi
case $service in case $service in
("help")
_arguments ':subcommand:($subcmds)'
;;
("show-flow") ("show-flow")
_arguments -A "-*" \ _arguments -A "-*" \
'-o[specify field to display]:field:(flow link ipaddr proto port dsfield)' \ '-o[specify field to display]:field:(flow link ipaddr proto port dsfield)' \

View file

@ -1,5 +1,5 @@
#compdef ipadm #compdef ipadm
# Synced with the S11U1 build 16 man page # Synced with the S11U1 build 19 man page
_ipadm_ifs() { _ipadm_ifs() {
local -a extra local -a extra
@ -81,6 +81,7 @@ _ipadm() {
local -a proto_all_properties proto_propproperties local -a proto_all_properties proto_propproperties
subcmds=( subcmds=(
"help"
{"show","disable","enable"}"-if" {"show","disable","enable"}"-if"
{"create","delete"}"-ip" {"create","delete"}"-ip"
{"create","delete"}"-vni" {"create","delete"}"-vni"
@ -153,6 +154,10 @@ _ipadm() {
fi fi
case $service in case $service in
("help")
_arguments ':subcommand:($subcmds)'
;;
("create-ip") ("create-ip")
_arguments -A "-*" \ _arguments -A "-*" \
'(-t --temporary)'{-t,--temporary}'[Interface should be temporary]' \ '(-t --temporary)'{-t,--temporary}'[Interface should be temporary]' \

View file

@ -1,5 +1,5 @@
#compdef zoneadm #compdef zoneadm
# Synced with the Solaris 11 build 168 man page # Synced with the S11U1 build 19 man page
_zoneadm_bootargs() { _zoneadm_bootargs() {
# This is a subset of the arguments to kernel(1M) # This is a subset of the arguments to kernel(1M)
@ -129,7 +129,7 @@ _zoneadm() {
("mark") ("mark")
_arguments -A "-*" \ _arguments -A "-*" \
':"incomplete":_values \"incomplete\" incomplete' ':state:(incomplete unavailable)'
;; ;;
("move") ("move")

View file

@ -1,5 +1,5 @@
#compdef zfs #compdef zfs
# Synced with the S11U1 build 16 man page # Synced with the S11U1 build 20 man page
_zfs() { _zfs() {
local context state line expl local context state line expl
@ -21,7 +21,7 @@ _zfs() {
"compressratio" "mounted" "origin" "usedbychildren" "compressratio" "mounted" "origin" "usedbychildren"
"usedbydataset" "usedbyrefreservation" "usedbysnapshots" "usedbydataset" "usedbyrefreservation" "usedbysnapshots"
"defer_destroy" "userused@" "userrefs" "groupused@" "defer_destroy" "userused@" "userrefs" "groupused@"
"keystatus" "rekeydate" "keychangedate" "keystatus" "rekeydate"
) )
# TODO: Be cleverer about what values can be set. Is there any way to # TODO: Be cleverer about what values can be set. Is there any way to
@ -111,12 +111,12 @@ _zfs() {
'-p[Create parent datasets]' \ '-p[Create parent datasets]' \
'-o[Set initial properties]:property:_values -s , "property" $create_properties' \ '-o[Set initial properties]:property:_values -s , "property" $create_properties' \
- set1 \ - set1 \
':filesystem:' \ ':filesystem:_zfs_dataset -t fs -e "parent dataset"' \
- set2 \ - set2 \
'-s[Create sparse volume]' \ '-s[Create sparse volume]' \
'-b[Set volblocksize]:blocksize:' \ '-b[Set volblocksize]:blocksize:' \
'-V[Set size]:size:' \ '-V[Set size]:size:' \
':volume:' ':volume:_zfs_dataset -t fs -e "parent dataset"'
;; ;;
("destroy") ("destroy")
@ -153,25 +153,20 @@ _zfs() {
'-K[Create encryption key]' \ '-K[Create encryption key]' \
'-o[Set property]:property:_values -s , "property" $create_properties' \ '-o[Set property]:property:_values -s , "property" $create_properties' \
':snapshot:_zfs_dataset -t snap' \ ':snapshot:_zfs_dataset -t snap' \
':filesystem/volume:' ':filesystem/volume:_zfs_dataset -t fs -e "parent dataset"'
;; ;;
("promote") ("promote")
# XXX complete only cloned filesystems
_arguments \ _arguments \
':filesystem:_zfs_dataset -t fs' \ ':filesystem:_zfs_dataset -t clone' \
;; ;;
("rename") ("rename")
_arguments -A "-*" \ _arguments -A "-*" \
- set1 \ '(-r)-p[Create parent datasets]' \
'-p[Create parent datasets]' \ '(-p)-r[Recursively rename snapshots of all descendent datasets]' \
':filesystem/volume/snapshot:_zfs_dataset' \ ':dataset:_zfs_dataset -r1' \
':filesystem/volume/snapshot:' \ ':dataset:_zfs_dataset -r2'
- set2 \
'-r[Recursively rename snapshots of all descendent datasets]' \
':snapshot:_zfs_dataset -t snap' \
':snapshot:'
;; ;;
("list") ("list")
@ -182,7 +177,7 @@ _zfs() {
'-o[Properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \ '-o[Properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \
'*-s[Sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \ '*-s[Sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \
'*-S[Sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \ '*-S[Sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \
'-t[Dataset types to list]:dataset type:_values -s , "dataset type" filesystem snapshot volume' \ '-t[Dataset types to list]:dataset type:_values -s , "dataset type" all filesystem snapshot volume' \
'*:filesystem/volume/snapshot/path:_zfs_dataset -p' '*:filesystem/volume/snapshot/path:_zfs_dataset -p'
;; ;;

View file

@ -1,5 +1,5 @@
#compdef zpool #compdef zpool
# Synced with the S11U1 build 16 man page # Synced with the S11U1 build 19 man page
_zpool() { _zpool() {
local context state line expl local context state line expl
@ -108,6 +108,7 @@ _zpool() {
(create) (create)
# TODO: investigate better vdev handling # TODO: investigate better vdev handling
_arguments -A "-*" \ _arguments -A "-*" \
'-B[Create EFI boot partition on whole disks]' \
'-o[Set pool property at creation time]:property:_values -s , "property" $rw_props' \ '-o[Set pool property at creation time]:property:_values -s , "property" $rw_props' \
'-O[Set dataset property at creation time]:property:_values -s , "property" $create_properties_dataset' \ '-O[Set dataset property at creation time]:property:_values -s , "property" $create_properties_dataset' \
'-f[Force use of in-use devices]' \ '-f[Force use of in-use devices]' \

View file

@ -1,13 +1,19 @@
#autoload #autoload
local -a type paths_allowed typearg datasetlist expl local -a type expl_type_arr rsrc rdst paths_allowed
local -a typearg datasetlist expl mlist
local expl_type local expl_type
zparseopts -D -E t+:=type p=paths_allowed # -e takes an argument which is passed as as the "descr" argument to _wanted
# -p indicates that filesystem paths, not just dataset names, are allowed
# -r1 indicates that we're completing the source of a rename
# -r2 indicates that we're completing the destination of a rename
# -t takes arguments (what kinds of datasets) and can appear multiple times
zparseopts -D -E e:=expl_type_arr p=paths_allowed r1=rsrc r2=rdst t+:=type
[[ -n $type[(r)fs] ]] && typearg=( filesystem ) [[ -n $type[(r)fs] ]] && typearg=( filesystem )
[[ -n $type[(r)vol] ]] && typearg=( $typearg volume ) [[ -n $type[(r)vol] ]] && typearg=( $typearg volume )
[[ -n $type[(r)snap] ]] && typearg=( $typearg snapshot ) [[ -n $type[(r)snap] ]] && typearg=( $typearg snapshot )
if [[ -n $typearg ]]; then if [[ -n $typearg ]]; then
typearg=( -t ${(j:,:)typearg} ) typearg=( -t ${(j:,:)typearg} )
# We know we're in zfs list if paths_allowed is non-empty. # We know we're in zfs list if paths_allowed is non-empty.
@ -20,7 +26,39 @@ if [[ ${#paths_allowed} -gt 0 && $PREFIX == /* ]]; then
return return
fi fi
datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} ) if [[ ${#rsrc} -gt 0 ]]; then
# With the -r option to zfs rename, we can only rename snapshots. With the
# -p option, we can only rename filesystems and volumes.
if [[ -n $words[(r)-r] ]]; then
typearg=( -t snapshot )
elif [[ -n $words[(r)-p] ]]; then
typearg=( -t filesystem,volume )
else
typearg=( -t filesystem,snapshot,volume )
fi
fi
if [[ ${#rdst} -gt 0 ]]; then
if [[ ${words[CURRENT - 1]} == *@* ]]; then
# If we're renaming snapshots, there's nothing to complete, so
# we simply give instructions. (In non-recursive cases, we
# could put the name of the snapshotted dataset first, but why
# bother with the long form?)
_message -e 'snapshot name (beginning with "@")'
return
else
# The parent dataset must be a filesystem, and can't rename
# a dataset into another pool. Plus we hardcode the expl.
typearg=( -t fs -r ${${words[CURRENT - 1]}%%/*} )
expl_type_arr=( -e "parent dataset" )
fi
fi
if [[ -n $type[(r)clone] ]]; then
datasetlist=( ${="$(zfs list -H -o name,origin -t fs | awk "\$2 != \"-\" {print \$1}")":#no cloned filesystems available} )
else
datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} )
fi
expl_type=${typearg[2,-1]//,/\/} expl_type=${typearg[2,-1]//,/\/}
if [[ -n $type[(r)mtpt] ]]; then if [[ -n $type[(r)mtpt] ]]; then
@ -29,4 +67,8 @@ if [[ -n $type[(r)mtpt] ]]; then
expl_type="$expl_type/mountpoint" expl_type="$expl_type/mountpoint"
fi fi
if [[ -n $expl_type_arr[2] ]]; then
expl_type=$expl_type_arr[2]
fi
_wanted dataset expl "$expl_type" _multi_parts "$@" -q / datasetlist _wanted dataset expl "$expl_type" _multi_parts "$@" -q / datasetlist