forked from pimutils/khal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__khal
90 lines (81 loc) · 2.95 KB
/
__khal
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#compdef khal
# install by copying to file where your zsh looks for completion scripts
# e.g. add this to your zshrc:
# fpath=(~/.zsh/completion $fpath)
_calendars() {
local expl
_wanted calendars expl calendar compadd \
${(f)"$(_call_program calendars khal printcalendars)"}
}
local curcontext="$curcontext" hlp="--help" ret=1
local -a args state line
local -A opt_args
args=( '(- *)--help[show help information]' )
_arguments -C $args \
{-c+,--config=}'[specify config file]:config file:_files' \
{-v+,--verbosity=}"[set verbosity level]:options:(CRITICAL ERROR WARNING INFO DEBUG)" \
{-l+,--logfile=}'[specify the file to log to]:log file:()' \
'(- *)--version[show version]' \
':subcommand:->subcommand' \
'*::options:->options' && ret=0
case $state in
subcommand)
local -a subcommands
subcommands=(
'at:show all events for given time'
"calendar:show calendar"
"configure: intitial configuration"
"edit:edit (or delete) an event"
"import:import an ics file into a calendar"
"interactive:open the interactive calendar"
"list:show list of events"
"new:add a new event"
"printcalendars:print all configured calendars"
"printformats:print a date in all formats"
"printics:print ics file without importing"
"search:search for events"
)
_describe -t subcommands 'khal subcommands' subcommands && ret=0
;;
options)
curcontext="${curcontext%:*}-${words[1]}:"
case $words[1] in
at | calendar | list | interactive | search | printcalendars | edit)
args+=(
"(-d --exclude-calendar $hlp)*"{-a+,--include-calendar=}'[specify calendar to use]:calendar:_calendars'
"(-a --include-calendar $hlp)*"{-d+,--exclude-calendar=}"[don't use this calendar]:calendar:_calendars"
)
;|
list | calendar)
args+=(
"($hlp)--days=[specify how many days to include]:days:_dates -f d -F"
"($hlp)--events=[specify how many events to include]:events"
)
;|
at | list) args+=( '*:date/time' ) ;;
new | import)
args+=(
"($hlp)-a+[specify calendar]:calendar:_calendars"
)
;|
import)
args+=(
"(-r --random_uid $hlp)"{-r,--random_uid}'[select a random uid]'
"($hlp)--batch[don't ask for any confirmation]"
'*:file:_files -g "*.ics(-.)"'
)
;;
new)
args+=(
"(-l --location $hlp)"{-l,--location=}'[specify location of event]:location'
"(-r --repeat $hlp)"{-r,--repeat=}'[repeat an event]:frequency:compadd -E0 - daily weekly monthly yearly'
"(-u --until $hlp)"{-u,--until=}'[specify date to stop an event repeating]:date'
"(-i --interactive $hlp)"{-i,--interactive=}'[interactively create a new event]'
':start date/time' '::end date/time' '::timezone' ':summary' ':description'
)
;;
esac
_arguments -A "-*" $args && ret=0
;;
esac
return ret