summaryrefslogtreecommitdiff
path: root/provides/zsh/completions/_envstore
blob: 19c4e7dba4bb5b163f52943c6f42416488adedfb (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
#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 -e | cut -d ' ' -f 2 | cut -d '=' -f 1)
}

if (( CURRENT >= 3 )) {
	case ${words[2]} in 
		eval)  _arguments -s '2::option:(-e)' ;;
		rm)    _arguments -s '2:saved parameter:_saved_param' ;;
		save)  _arguments -s '2:parameter:_parameters -g "(scalar|integer)*export"' ;;
	esac
} elif [[ -r /tmp/envstore-$UID ]] {
	_describe command options
} else {
	_describe command options_nofile
}