mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-06 23:31:28 +02:00
35879: fix for subcommands that don't have a second subcommand
This commit is contained in:
parent
8f8b82bc6c
commit
acf1fa6034
2 changed files with 137 additions and 133 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-07-24 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 35879: Eric Cook: Completion/Linux/Command/_btrfs: fix for
|
||||
subcommands that don't have a second subcommand
|
||||
|
||||
2015-07-24 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 35883: Src/hist.c: Don't attempt to back up over history if
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#compdef btrfs
|
||||
# based on Btrfs v3.12+20131125
|
||||
|
||||
local curcontext="$curcontext" curstate state line expl grp cmd ret=1
|
||||
local curcontext="$curcontext" curstate state line expl grp cmd cont shift ret=1
|
||||
local -a cmds_1 cmds_2 cmds_3 cmds_4 cmds_5 cmds_6 cmds_7 cmds_8 cmds_9 cmds_10
|
||||
local -a groups args
|
||||
|
||||
|
@ -36,79 +36,32 @@ while (( $#state )); do
|
|||
_wanted command-groups expl 'btrfs command group' compadd -a groups && ret=0
|
||||
;;
|
||||
cmds)
|
||||
: $words
|
||||
local grp=${groups[(i)$words[2]*]}
|
||||
: $grp
|
||||
grp=${groups[(i)$words[2]*]}
|
||||
(( grp && grp <= 14 )) || return 1
|
||||
curcontext="${curcontext%:*:*}:$service-${groups[grp]}:"
|
||||
case $grp in
|
||||
11)
|
||||
# btrfs check
|
||||
args+=(
|
||||
{-s,--support}'[specify superblock]:superblock: _message "superblock"'
|
||||
'--repair[try to repair the filesystem]'
|
||||
'--init-csum-tree[create a new CRC tree]'
|
||||
'--init-extent-tree[create a new extent tree]'
|
||||
'1:path:_files -/'
|
||||
)
|
||||
;|
|
||||
12)
|
||||
# btrfs replace
|
||||
args+=(
|
||||
'-s[get snapshots]'
|
||||
'-x[get extended attributes]'
|
||||
'-v[verbose]'
|
||||
'-i[ignore errors]'
|
||||
'-o[overwrite]'
|
||||
'-t[tree location]:tree:_message "tree location"'
|
||||
'-f[filesystem location]:filesystem:_message "filesystem location"'
|
||||
'-u[super mirror]:mirror:_message "super mirror"'
|
||||
'-r[root objectid]:objectid:_message "root objectid"'
|
||||
'-d[find dir]'
|
||||
'-l[list tree roots]'
|
||||
'--path-regex[restore matching filenames]:regex:_message "regex"'
|
||||
'1:device:_files -/'
|
||||
'2:path:_files -/'
|
||||
)
|
||||
;|
|
||||
13)
|
||||
# btrfs send
|
||||
args+=(
|
||||
'*-v[verbose mode]'
|
||||
'-p[send incremental stream]:parent:_files -/'
|
||||
'*-c[use snapshot as clone source]:clone:_files -/'
|
||||
'-f[output file]:file:_files'
|
||||
'1:subvol:_files -/'
|
||||
)
|
||||
;|
|
||||
14)
|
||||
# btrfs receive
|
||||
args+=(
|
||||
'*-v[verbose mode]'
|
||||
'-f[input file]:file: _files'
|
||||
'-e[terminate after <end cmd>]'
|
||||
'1:mount:->mounts'
|
||||
)
|
||||
;|
|
||||
<11-14>)
|
||||
(( CURRENT-- )); shift words; curcontext="${curcontext%:*:*}:$service-${group[grp]}:"
|
||||
_arguments -C "$args[@]" && ret=0
|
||||
;;
|
||||
<0-10>)
|
||||
cont=${groups[grp]}
|
||||
curcontext="${curcontext%:*:*}:$service-${cont}:"
|
||||
if (( grp <= 10 )); then
|
||||
_wanted commands expl command compadd -a cmds_$grp && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
continue
|
||||
fi
|
||||
;&
|
||||
args)
|
||||
: $words
|
||||
local grp=${groups[(i)$words[1]*]}
|
||||
if [[ $curstate != cmds ]]; then
|
||||
grp=${groups[(i)$words[1]*]}
|
||||
(( grp && grp <= 15 )) || return 1
|
||||
cont=${groups[grp]}
|
||||
if (( grp <= 10 )); then
|
||||
local group=cmds_$grp
|
||||
local cmd=${${(P)group}[(i)$words[2]*]}
|
||||
(( cmd )) || return 1
|
||||
curcontext="${curcontext%:*:*}:$service-${groups[grp]}-${${(P)group}[cmd]}:"
|
||||
cont+=:${${(P)group}[cmd]}
|
||||
else
|
||||
shift=1
|
||||
fi
|
||||
curcontext="${curcontext%:*:*}:$service-${cont/:/-}:"
|
||||
fi
|
||||
args=( '(-)--help[print help information]' )
|
||||
case ${groups[grp]}:${${(P)group}[cmd]} in
|
||||
case ${cont} in
|
||||
filesystem:balance)
|
||||
if (( CURRENT == 3 )); then
|
||||
state+=cmds
|
||||
|
@ -210,8 +163,8 @@ while (( $#state )); do
|
|||
'1:path:_files -/'
|
||||
)
|
||||
;;
|
||||
balance:status) args+=( '-v[verbose mode]' '2:path:_files -/' );;
|
||||
balance:(pause|cancel|resume)) args+=( '2:path:_files -/' );;
|
||||
balance:status) args+=( '-v[verbose mode]' '1:path:_files -/' );;
|
||||
balance:(pause|cancel|resume)) args+=( '1:path:_files -/' );;
|
||||
quota:(enable|disable)) args+=( '1:path:_files -/' );;
|
||||
quota:rescan)
|
||||
args+=(
|
||||
|
@ -279,10 +232,56 @@ while (( $#state )); do
|
|||
subvolume:get-default) ;&
|
||||
*:sync) ;&
|
||||
*:df) args+=( '1:path:->mounts' );;
|
||||
check)
|
||||
args+=(
|
||||
{-s,--support}'[specify superblock]:superblock'
|
||||
'--repair[try to repair the filesystem]'
|
||||
'--init-csum-tree[create a new CRC tree]'
|
||||
'--init-extent-tree[create a new extent tree]'
|
||||
'1:path:_files -/'
|
||||
)
|
||||
;;
|
||||
restore)
|
||||
args+=(
|
||||
'-s[get snapshots]'
|
||||
'-x[get extended attributes]'
|
||||
'-v[verbose]'
|
||||
'-i[ignore errors]'
|
||||
'-o[overwrite]'
|
||||
'-t[tree location]:tree'
|
||||
'-f[filesystem location]:filesystem'
|
||||
'-u[super mirror]:mirror'
|
||||
'-r[root objectid]:objectid'
|
||||
'-d[find dir]'
|
||||
'-l[list tree roots]'
|
||||
'--path-regex[restore matching filenames]:regex'
|
||||
'1:device:_files -/'
|
||||
'2:path:_files -/'
|
||||
)
|
||||
;;
|
||||
send)
|
||||
args+=(
|
||||
'*-v[verbose mode]'
|
||||
'-p[send incremental stream]:parent:_files -/'
|
||||
'*-c[use snapshot as clone source]:clone:_files -/'
|
||||
'-f[output file]:file:_files'
|
||||
'1:subvolume:_files -/'
|
||||
)
|
||||
;;
|
||||
receive)
|
||||
args+=(
|
||||
'*-v[verbose mode]'
|
||||
'-f[input file]:file: _files'
|
||||
'-e[terminate after <end cmd>]'
|
||||
'1:mount:->mounts'
|
||||
)
|
||||
;;
|
||||
*) args+=( '*: :_default' );; # fallback for unknown subcommands
|
||||
esac
|
||||
if ! (( shift )); then
|
||||
shift words
|
||||
(( CURRENT-- ))
|
||||
fi
|
||||
_arguments -C "$args[@]" && ret=0
|
||||
;;
|
||||
mounts)
|
||||
|
|
Loading…
Reference in a new issue