Merge pull request #1029 from zsh-users/refactor-udisksctl
Refactoring udisksctl completion
This commit is contained in:
commit
4172b053de
214
src/_udisksctl
214
src/_udisksctl
|
@ -27,8 +27,7 @@
|
||||||
# Description
|
# Description
|
||||||
# -----------
|
# -----------
|
||||||
#
|
#
|
||||||
# Completion script for udisksctl
|
# Completion script for udisksctl (https://github.com/storaged-project/udisks)
|
||||||
# (https://cgit.freedesktop.org/udisks/tree/tools)
|
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Authors
|
# Authors
|
||||||
|
@ -48,117 +47,130 @@
|
||||||
# upstream bash completion. In the future one might consider rewriting using
|
# upstream bash completion. In the future one might consider rewriting using
|
||||||
# that. (but not sure how straight forward it would be to provide descriptions?)
|
# that. (but not sure how straight forward it would be to provide descriptions?)
|
||||||
#
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
_paths() {
|
(( $+functions[_udisksctl_paths] )) ||
|
||||||
local -a _path_list
|
_udisksctl_paths() {
|
||||||
|
local -a _path_list
|
||||||
|
|
||||||
for _path in $(_call_program paths "udisksctl complete \"udisksctl $words\" $CURSOR" | sed 's/:/\\:/g'); do
|
for _path in $(_call_program paths "udisksctl complete \"udisksctl $words\" $CURSOR" | sed 's/:/\\:/g'); do
|
||||||
_path_list+=$_path
|
_path_list+=$_path
|
||||||
done
|
done
|
||||||
|
|
||||||
_describe 'path' _path_list
|
_describe 'path' _path_list
|
||||||
}
|
}
|
||||||
|
|
||||||
_filesystems() {
|
(( $+functions[_udisksctl_filesystems] )) ||
|
||||||
_fs_types=(
|
_udisksctl_filesystems() {
|
||||||
'adfs' 'affs' 'autofs' 'cifs' 'coda' 'coherent' 'cramfs' 'debugfs' 'devpts'
|
local -a _fs_types=(
|
||||||
'efs' 'ext' 'ext2' 'ext3' 'ext4' 'hfs' 'hfsplus' 'hpfs' 'iso9660' 'jfs' 'minix'
|
'adfs' 'affs' 'autofs' 'btrfs' 'ceph' 'cifs' 'coda' 'coherent' 'cramfs'
|
||||||
'msdos' 'ncpfs' 'nfs' 'nfs4' 'ntfs' 'proc' 'qnx4' 'ramfs' 'reiserfs' 'romfs'
|
'debugfs' 'devpts' 'efs' 'exfat' 'ext' 'ext2' 'ext3' 'ext4' 'hfs' 'hfsplus'
|
||||||
'squashfs' 'smbfs' 'sysv' 'tmpfs' 'ubifs' 'udf' 'ufs' 'umsdos' 'usbfs' 'vfat'
|
'hpfs' 'iso9660' 'jfs' 'minix' 'msdos' 'ncpfs' 'nfs' 'nfs4' 'ntfs' 'proc'
|
||||||
'xenix' 'xfs' 'xiafs'
|
'qnx4' 'ramfs' 'reiserfs' 'romfs' 'squashfs' 'smbfs' 'sysv' 'tmpfs' 'ubifs'
|
||||||
)
|
'udf' 'ufs' 'umsdos' 'usbfs' 'vfat' 'xenix' 'xfs' 'xiafs'
|
||||||
|
)
|
||||||
|
|
||||||
_describe 'file system type' _fs_types
|
_describe 'file system type' _fs_types
|
||||||
}
|
}
|
||||||
|
|
||||||
_udisksctl() {
|
_udisksctl() {
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
local curcontext="$curcontext" state line ret=1
|
local curcontext="$curcontext" state line ret=1
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'1:udisksctl commands:->cmds' \
|
'1:udisksctl commands:->cmds' \
|
||||||
'*:: :->cmd_args' && ret=0
|
'*:: :->cmd_args' && ret=0
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
cmds)
|
cmds)
|
||||||
local commands; commands=(
|
local commands; commands=(
|
||||||
'help:show help'
|
'help:show help'
|
||||||
'info:show info about an object'
|
'info:show info about an object'
|
||||||
'dump:show info about all object'
|
'dump:show info about all object'
|
||||||
'status:shows high-level status'
|
'status:shows high-level status'
|
||||||
'monitor:monitor changes to objects'
|
'monitor:monitor changes to objects'
|
||||||
'mount:mount a filesystem'
|
'mount:mount a filesystem'
|
||||||
'unmount:unmount a filesystem'
|
'unmount:unmount a filesystem'
|
||||||
'unlock:unlock an encrypted device'
|
'unlock:unlock an encrypted device'
|
||||||
'lock:lock an encrypted device'
|
'lock:lock an encrypted device'
|
||||||
'loop-setup:set-up a loop device'
|
'loop-setup:set-up a loop device'
|
||||||
'loop-delete:delete a loop device'
|
'loop-delete:delete a loop device'
|
||||||
'power-off:safely power off a drive'
|
'power-off:safely power off a drive'
|
||||||
'smart-simulate:set SMART data for a drive'
|
'smart-simulate:set SMART data for a drive'
|
||||||
)
|
)
|
||||||
_describe -t commands 'udisksctl command' commands && ret=0
|
_describe -t commands 'udisksctl command' commands && ret=0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
cmd_args)
|
cmd_args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
info)
|
info)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[specify object to get information about]:object path:_paths' \
|
{-p,--object-path}'[specify object to get information about]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[specify block device to get information about]:block device:_paths' \
|
{-b,--block-device}'[specify block device to get information about]:block device:_udisksctl_paths' \
|
||||||
{-d,--drive}'[specify drive to get information about]:drive:_paths' && ret=0
|
{-d,--drive}'[specify drive to get information about]:drive:_udisksctl_paths' && ret=0
|
||||||
;;
|
;;
|
||||||
mount)
|
mount)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[specify object to mount]:object path:_paths' \
|
{-p,--object-path}'[specify object to mount]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[specify block device to mount]:block device:_paths' \
|
{-b,--block-device}'[specify block device to mount]:block device:_udisksctl_paths' \
|
||||||
{-t,--filesystem-type}'[specify filesystem type to use]:fs type:_filesystems' \
|
{-t,--filesystem-type}'[specify filesystem type to use]:fs type:_udisksctl_filesystems' \
|
||||||
{-o,--options}'[mount options]' \
|
{-o,--options}'[mount options]' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
unmount)
|
unmount)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[object to unmount]:object path:_paths' \
|
{-p,--object-path}'[object to unmount]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[block device to unmount]:block device:_paths' \
|
{-b,--block-device}'[block device to unmount]:block device:_udisksctl_paths' \
|
||||||
{-f,--force}'[force/lazy unmount]' \
|
{-f,--force}'[force/lazy unmount]' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't auhenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
unlock|lock)
|
unlock|lock)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[object to lock/unlock]:object path:_paths' \
|
{-p,--object-path}'[object to lock/unlock]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[block device to lock/unlock]:block device:_paths' \
|
{-b,--block-device}'[block device to lock/unlock]:block device:_udisksctl_paths' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
loop-setup)
|
loop-setup)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-f,--file}'[specify file to set-up a loop device for]:files:_files' \
|
{-f,--file}'[specify file to set-up a loop device for]:files:_files' \
|
||||||
{-r,--read-only}'[setup read-only device]' \
|
{-r,--read-only}'[setup read-only device]' \
|
||||||
{-o,--offset}'[start at specified offset into file]:offset (bytes)' \
|
{-o,--offset}'[start at specified offset into file]:offset (bytes)' \
|
||||||
{-s,--size}'[limit size]:limit (bytes)' \
|
{-s,--size}'[limit size]:limit (bytes)' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
loop-delete)
|
loop-delete)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[object for loop device to delete]:object path:_paths' \
|
{-p,--object-path}'[object for loop device to delete]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[loop device to delete]:block device:_paths' \
|
{-b,--block-device}'[loop device to delete]:block device:_udisksctl_paths' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
power-off)
|
power-off)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-p,--object-path}'[object path for ATA device]:object path:_paths' \
|
{-p,--object-path}'[object path for ATA device]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[device file for ATA device]:block device:_paths' \
|
{-b,--block-device}'[device file for ATA device]:block device:_udisksctl_paths' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
smart-simulate)
|
smart-simulate)
|
||||||
_arguments \
|
_arguments \
|
||||||
{-f,--file}'[file with libatasmart blob]:files:_files' \
|
{-f,--file}'[file with libatasmart blob]:files:_files' \
|
||||||
{-p,--object-path}'[object to get information about]:object path:_paths' \
|
{-p,--object-path}'[object to get information about]:object path:_udisksctl_paths' \
|
||||||
{-b,--block-device}'[block device to get information about]:block device:_paths' \
|
{-b,--block-device}'[block device to get information about]:block device:_udisksctl_paths' \
|
||||||
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
"(--no-user-interaction)--no-user-interaction[don't authenticate the user if needed]" && ret=0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
return ret
|
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
_udisksctl "$@"
|
_udisksctl "$@"
|
||||||
|
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
|
Loading…
Reference in New Issue