diff options
-rw-r--r-- | etc/completions/_cryptsetup | 113 |
1 files changed, 80 insertions, 33 deletions
diff --git a/etc/completions/_cryptsetup b/etc/completions/_cryptsetup index 30d70cc..854bfd2 100644 --- a/etc/completions/_cryptsetup +++ b/etc/completions/_cryptsetup @@ -1,51 +1,98 @@ #compdef cryptsetup function _cryptsetup_action { - typeset expl - _wanted action expl action \ - compadd create remove status resize \ - luks{Format,Open,Close,{Add,Remove}Key} \ - luks{KillSlot,UUID,Dump} \ - isLuks + typeset -a actions + actions=( + 'create:create a mapping' + 'remove:remove an existing mapping' + 'status:report mapping status' + 'resize:resize an active mapping' + 'luksFormat:Initialize a LUKS partition' + 'luksOpen:Open LUKS partition' + 'luksClose:remove an existing mapping' + 'luksSuspend:suspend active device' + 'luksResume:resume suspended device' + 'luksAddKey:add a new key' + 'luksRemoveKey:remove a key' + 'luksChangeKey:change a key' + 'luksKillSlot:wipe key from slot' + 'luksUUID:print/change device UUID' + 'isLuks:check if device is a LUKS partition' + 'luksDump:dump header information' + 'luksHeaderBackup:store binary backup of headers' + 'luksHeaderRestore:restore header backup' + ) + _describe action actions } function _cryptsetup_device { + typeset expl + _wanted file expl device \ _files } function _cryptsetup_mapping { + typeset expl + _wanted file expl 'mapping name' \ _path_files -W /dev/mapper } function _cryptsetup_arguments { - if (( CURRENT == 2 )) { - case ${words[1]} in - create|remove|status|resize|luksClose) _cryptsetup_mapping ;; - luks(Format|Open|AddKey|RemoveKey|KillSlot|DelKey|UUID|Dump)|isLuks) _cryptsetup_device ;; - esac - } elif (( CURRENT == 3 )) { - case ${words[1]} in - create) _cryptsetup_device ;; - luksOpen) _cryptsetup_mapping ;; - esac - } + + case ${words[1]} in + + create) + _arguments ':mapping:_cryptsetup_mapping' ':device:_cryptsetup_device' + ;; + + remove|status|resize|luksClose|luksSuspend|luksResume) + _arguments ': :_cryptsetup_mapping' + ;; + + luks(AddKey|RemoveKey|DelKey|UUID|Dump)|isLuks) + _arguments ': :_cryptsetup_device' + ;; + + luks(Format|AddKey|RemoveKey|ChangeKey)) + _arguments ': :_cryptsetup_device' ':key file:_files' + ;; + + luksKillSlot) + _arguments ': :_cryptsetup_device' ':key slot number' + ;; + + luksOpen) + _arguments ': :_cryptsetup_device' ': :_cryptsetup_mapping' + ;; + + esac } -_arguments -n \ - {-h,--hash}':hash' \ - {-c,--cipher}':cipher specification' \ - {-y,--verify-passphrase} \ - {-d,--key-file}':key file:_files' \ - {-S,--key-slot}':key slot' \ - {-s,--key-size}':key size (bits)' \ - {-b,--size}':device size (sectors)' \ - {-o,--offset}':start offset' \ - {-p,--skip}':skip data (sectors)' \ - --readonly \ - {-i,--iter-time}':password processing time (milliseconds)' \ - {-q,--batch-mode} \ - {-t,--timeout}':password timeout (seconds)' \ - {-T,--tries}':passwort retries' \ - '--align-payload=-:payload boundary align (512-byte sectors)' \ +_arguments \ + '(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \ + '--debug[enable debug mode]' \ + '(-h --hash)'{-h,--hash}'[hash algorithm]:hash algorithm' \ + '(-c --cipher)'{-c,--cipher}'[set cipher]:cipher specification' \ + '(-y --verify-passphrase)'{-y,--verify-passphrase}'[query for password twice]' \ + '(-d --key-file)'{-d,--key-file}'[set keyfile]:key file:_files' \ + '(-l --keyfile-size)'{-l,--keyfile-size}'[set keyfile size]:bytes' \ + '--new-keyfile-size[set new keyfile size (luksAddKey)]:bytes' \ + '--master-key-file[set master key]:key file:_files' \ + '--dump-master-key[dump luks master key]' \ + '(--use-urandom)--use-random[use /dev/random to generate volume key]' \ + '(--use-random)--use-urandom[use /dev/urandom to generate volume key]' \ + '(-S --key-slot)'{-S,--key-slot}'[select key slot]:key slot' \ + '(-s --key-size)'{-s,--key-size}'[set key size]:bits' \ + '(-b --size)'{-b,--size}'[force device size]:sectors' \ + '(-o --offset)'{-o,--offset}'[set start offset]:sectors' \ + '(-p --skip)'{-p,--skip}'[data to skip at beginning]:sectors' \ + '--readonly[set up read-only mapping]' \ + '(-i --iter-time)'{-i,--iter-time}'[set password processing duration]:milliseconds' \ + '(-q --batch-mode)'{-q,--batch-mode}'[do not ask for confirmation]' \ + '(-t --timeout)'{-t,--timeout}'[set password prompt timeout]:seconds' \ + '(-T --tries)'{-T,--tries}'[set maximum number of retries]:maximum retries' \ + '--align-payload[set payload alignment]:sectors' \ + '--uuid[set device UUID]:uuid' \ + '--version[show version information]' \ ':action:_cryptsetup_action' \ '*::arguments:_cryptsetup_arguments' |