summaryrefslogtreecommitdiff
path: root/provides/zsh/completions/_envstore
blob: 585136280d693b634dd9450af9d37a31498b459e (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 envstore
## vim:ft=zsh
## completion for envstore release-3
## Daniel Friesel <derf@derf.homelinux.org>
## https://derf.homelinux.org/~derf/dotfiles/completion/_envstore
## see also: http://git.cloudconnected.org/?p=envstore.git;a=summary

local -a options options_nofile

options=(
	'clear:forget stored parameters'
	'eval:generate shell code to set parameters'
	'list:list saved parameters in human-readable format'
	'rm:delete saved parameter'
	'save:save parameter'
)

options_nofile=(
	'save:save parameter'
)

function _saved_param () {
	_wanted parameter expl 'saved parameter' \
	compadd $(envstore eval | cut -d ' ' -f 2 | cut -d '=' -f 1)
}

if (( CURRENT == 2 )) {
	if [[ -r /tmp/envstore-$UID ]] {
		_describe command options
	} else {
		_describe command options_nofile
	}
} elif (( CURRENT == 3 )) {
	case ${words[2]} in
		e*)
			_arguments -s '2::option:(-e)'
		;;
		r*)
			_saved_param
		;;
		s*)
			_parameters -g '(scalar|integer)*export*'
		;;
		*)
			_message 'no more arguments'
	esac
} elif [[ $CURRENT == 4 && ${words[2]} == save ]] {
	_message 'value'
} else {
	_message 'no more arguments'
}