summaryrefslogtreecommitdiff
path: root/etc/completions/_cryptsetup
blob: 5a327b37b63e780e9124ce5b01c69a4765268719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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
}

function _cryptsetup_device {
	_files
}

function _cryptsetup_mapping {
	_path_files -W /dev/mapper
}

function _cryptsetup_arguments {
	if (( CURRENT == 2 )) {
		case $words[1] in
			create|remove|status|resize) _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
	}
}

_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)' \
	':action:_cryptsetup_action' \
	'*::arguments:_cryptsetup_arguments'