summaryrefslogtreecommitdiff
path: root/etc/completions/_efa
blob: 0da0df3ee34b681f7f54b5bfc01416d1dd94ddd6 (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
52
53
54
55
56
57
#compdef efa
## completion for efa 1.0.5, based on efa(1)

function _efa_include {
	typeset -a types
	types=(
		'local:only take local trains (default)'
		'ic:local trains + IC'
		'ice:All kind of trains'
	)
	_describe 'train type' types
}

function _efa_prefer {
	typeset -a preferences
	preferences=(
		'speed:prefer fast connections'
		'nowait:prefer connections with little interchanges'
		'nowalk:prefer connections with little walking at interchanges'
	)
	_describe 'connection preference' preferences
}

function _efa_transports {
	typeset -a keys used_prefixes
	typeset prefix=''
	keys=(zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus schnellbus
		seilbahn schiff ast sonstige)

	if [[ -prefix *, ]] {
		prefix=${words[$CURRENT]%,*},
		used_prefixes=(${(s:,:)prefix})
	}
	_wanted expression expl 'mode of transportation' \
	compadd -F used_prefixes -qS , -P "$prefix" $keys
}

function _efa {
	_arguments -s \
	{--from,--to,--via}':city: :stop: ' \
	'(-t --time --depart)'{-t,--time,--depart}'[departure time]:HH\:MM' \
	'(-a --arrive)'{-a,--arrive}'[arrival time]:HH\:MM' \
	'(-d --date)'{-d,--date}'[journey date]:DD.MM.[YYYY]' \
	'(-b --bike)'{-b,--bike}'[prefer connections allowing bike take-along]' \
	'(-e --exclude)'{-e,--exclude}'[exclude transport types]: :_efa_transports' \
	'(-m --max-change)'{-m,--max-change}'[maximum number of interchanges]:number' \
	'(-P --prefer)'{-P,--prefer}'[set connection preference]:preference:_efa_prefer' \
	'(-p --proximity)'{-p,--proximity}'[take close stops into account]' \
	'(-i --include)'{-i,--include}'[use extra connection types]:type:_efa_include' \
	'(-w --walk-speed)'{-w,--walk-speed}'[set walking speed]:speed:(normal fast slow)' \
	'(-I --ignore-info)'{-I,--ignore-info}'[ignore information]:regular expression' \
	'--timeout[set request timeout]:seconds' \
	'--post[set custom POST key]:key=value' \
	'(-v --version)'{-v,--version}'[show version information]'
}

_efa "$@"