summaryrefslogtreecommitdiff
path: root/etc/completions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-09 16:39:58 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-09 16:39:58 +0200
commitc2a2a7aa3058f11cff0972fef74bb59b67ffa83b (patch)
tree7f884f50c81c0f813e0fab1d545883ad165fe2c0 /etc/completions
parent1015b75c91f8bd94d57f7484e8cd4d2e263cfc97 (diff)
Add efa completion
Diffstat (limited to 'etc/completions')
-rw-r--r--etc/completions/_efa63
1 files changed, 63 insertions, 0 deletions
diff --git a/etc/completions/_efa b/etc/completions/_efa
new file mode 100644
index 0000000..8b057f2
--- /dev/null
+++ b/etc/completions/_efa
@@ -0,0 +1,63 @@
+#compdef efa
+
+typeset -a arguments
+typeset -A argument_pairs argument_postfix
+typeset arg
+
+argument_pairs=(
+ time t+
+ arrive a+
+ date d+
+ bike b
+ exclude e+
+ max-change m+
+ prefer P+
+ proximity p
+ include i+
+ walk-speed w+
+ ignore-info I+
+ version v
+)
+
+argument_postfix=(
+ time '[Journey start time]:timestamp'
+ arrive '[Journey end time]:timestamp'
+ date '[Journey date]:date'
+ bike '[Prefer connections where you can take a bike with you]'
+ exclude '[Exclude transport types]:transport type:_efa_transports'
+ max-change '[Maximum interchanges]:maximum interchange number'
+ prefer '[Prefer connections]:connection type:(speed nowait nowalk)'
+ proximity '[Take close stops into account]'
+ include '[Include extra connection types]:connection type:(local ic ice)'
+ walk-speed '[Walk speed]:walk speed:(normal fast slow)'
+ ignore-info '[Ignore additional information]:regex'
+ verison '[Print version information]'
+)
+
+arguments=(
+ '--'{from,to,via}':city: :stop: '
+ '--'{from,to,via}'-type:type:(stop address poi)'
+ '(--depart --arrive)--time:time'
+ '(--depart --time)--arrive:time'
+ '(--arrive --time)--depart:time'
+ '*--post:POST key=value'
+)
+
+for arg in ${(k)argument_pairs}; {
+ arguments+='(--'${arg}')-'${argument_pairs[$arg]}${argument_postfix[$arg]}
+ arguments+='(-'${${argument_pairs[$arg]}[1]}')--'${arg}${argument_postfix[$arg]}
+}
+
+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 'sort expression' \
+ compadd -F used_prefixes -qS , -P "$prefix" $keys
+}
+_arguments -s $arguments