summaryrefslogtreecommitdiffstats
path: root/useful/zsh-completion/openslx/_openslx
blob: f19f4973a154ce1bdc22a5ad99b6984da4ae785d (plain) (blame)
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
#compdef openslx
#autoload

typeset -A opt_args
local context state state_descr line expl

_openslx_targets() {
	targets=(`ls server/local_builds/$1`)
}

local -a targets _local_builds configs
_local_builds=(`ls server/local_builds/`)
configs=(`ls server/configs/`)

_arguments \
	"--help[display help text]: :->help" \
	"*:: :->remotehost" && return 0

if (( CURRENT == 1 )); then
	_describe -t commands "Existing Remote Hosts" _local_builds
	return
fi

case "$state" in
	remotehost)
		_openslx_targets $words[1]
		[[ "$targets" == "server/local_builds/local" ]] && unset targets

		_arguments \
			"(-k :)-s[sync 'builds' from remote host]" \
			"(-s :)-k[-k <config> - generate config file server/boot/<remotehost>/configs/<configname>/config.tgz]:Available Configs:($configs)" \
			"(:)-d[activates debug output for the task (spamy)]" \
			"(-)*: :->target" \
			&& return 0

			if [[ "$state" == target ]]; then
				_arguments \
					"-e[-e type - export target as 'type'. can be 'cpio' (simple initramfs) or 'sqfs' (squashfs)]:Export Type:(sqfs cpio)" \
					"-s[sync 'builds' from remote host]" \
					"-c[clean target in server/local_builds/ and corresponding files under boot/]" \
					"-d[activates debug output for the task]" \
					":Targets on Host $words[1]:($targets)"
			fi
	;;
esac