| 1 |
#compdef udisksctl |
| 2 |
|
| 3 |
# Completion function for zsh |
| 4 |
|
| 5 |
local curcontext="$curcontext" cmd="$words[1]" params ca_opts |
| 6 |
local -i i ret=1 |
| 7 |
local -a state state_descr line expl cmds opts vals |
| 8 |
|
| 9 |
if (( CURRENT == 2 )); then |
| 10 |
cmds=( $(_call_program commands $cmd complete "$cmd" ${#cmd}) ) |
| 11 |
_wanted commands expl "command" compadd -M "r:|-=* r:|=*" -a cmds |
| 12 |
else |
| 13 |
curcontext="${curcontext%:*}-${words[2]}:" |
| 14 |
opts=( $(_call_program options $cmd complete "${(q)words[1,2]}" ${(c)#words[1,2]}) ) |
| 15 |
for ((i=$#opts;i;i--)); do |
| 16 |
case $opts[i] in |
| 17 |
--block-device) |
| 18 |
opts[i]=( '(-b --block-device -d --drive -p --object-path)'{-b,--block-device=}'[specify block device]:block device:->block-devices' ) |
| 19 |
;; |
| 20 |
--drive) |
| 21 |
opts[i]=( '(-d --drive -b --block-device -p --object-path)'{-d,--drive=}'[specify drive]:drive:->drives' ) |
| 22 |
;; |
| 23 |
--force) |
| 24 |
opts[i]=( '(-f --force)'{-f,--force} ) |
| 25 |
;; |
| 26 |
--file) |
| 27 |
opts[i]=( '(-f --file)'{-f,--file=}'[specify filename]:file:_files' ) |
| 28 |
;; |
| 29 |
--filesystem-type) |
| 30 |
opts[i]=( '(-t --filesystem-type)'{-t,--filesystem-type=}'[specify filesystem type to use]: :_file_systems' ) |
| 31 |
;; |
| 32 |
--no-user-interaction) |
| 33 |
opts[i]=( "--no-user-interaction[don't authenticate the user if needed]" ) |
| 34 |
;; |
| 35 |
--offset) |
| 36 |
opts[i]=( '(-o --offset)'{-o,--offset}'[specify offset]:offset (bytes)' ) |
| 37 |
;; |
| 38 |
--object-path) |
| 39 |
opts[i]=( '(-p --object-path -b --block-device -d --drive)'{-p,--object-path=}'[specify object]:object path:->object-paths' ) |
| 40 |
;; |
| 41 |
--options) |
| 42 |
opts[i]=( '(-o --options)'{-o,--options=}'[specify mount options]:mount options' ) |
| 43 |
;; |
| 44 |
--read-only) |
| 45 |
opts[i]=( '(-r --read-only)'{-r,--read-only} ) |
| 46 |
;; |
| 47 |
--size) |
| 48 |
opts[i]=( '(-s --size)'{-s,--size=}'[specify size]:size (bytes)' ) |
| 49 |
;; |
| 50 |
esac |
| 51 |
done |
| 52 |
shift words |
| 53 |
(( CURRENT-- )) |
| 54 |
_arguments -S -C '(-)--help[display usage information]' $opts && ret=0 |
| 55 |
|
| 56 |
if [[ -n $state ]]; then |
| 57 |
params="$cmd $words[1] " |
| 58 |
case $state in |
| 59 |
block-devices) params+="--block-device" ca_opts=( -M "r:|/=* r:|=*" ) ;; |
| 60 |
drives) params+="--drive" ca_opts=( -M "r:|_=* r:|=*" ) ;; |
| 61 |
object-paths) params+="--object-path" ca_opts=( -f -M "r:|/=* r:|=*" ) ;; |
| 62 |
esac |
| 63 |
vals=( $(_call_program values $cmd complete "${(q)params}" $#params) ) |
| 64 |
_description values expl $state_descr |
| 65 |
compadd "$expl[@]" $ca_opts -a vals && ret=0 |
| 66 |
fi |
| 67 |
return ret |
| 68 |
fi |