Skip to content

Commit 869192d

Browse files
committed
Add zsh completions
1 parent 80179d5 commit 869192d

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARCHIVE=$(EXECUTABLE).tar.gz
77
SRC=$(wildcard Sources/*.swift)
88

99
clean:
10-
rm -f $(EXECUTABLE) $(ARCHIVE)
10+
rm -f $(EXECUTABLE) $(ARCHIVE) _reminders
1111
swift build --clean
1212

1313
build: $(SRC)
@@ -19,10 +19,11 @@ release: clean
1919
-Xswiftc -static-stdlib
2020

2121
package: release
22-
tar -pvczf $(ARCHIVE) -C $(RELEASE_BUILD) $(EXECUTABLE)
22+
tar -pvczf $(ARCHIVE) -C zsh _reminders -C ../$(RELEASE_BUILD) $(EXECUTABLE)
2323
tar -zxvf $(ARCHIVE)
2424
@shasum -a 256 $(ARCHIVE)
2525
@shasum -a 256 $(EXECUTABLE)
26+
rm $(EXECUTABLE) _reminders
2627

2728
install: release
2829
install $(RELEASE_BUILD)/$(EXECUTABLE) $(PREFIX)

zsh/_reminders

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#compdef reminders
2+
3+
_get_lists() {
4+
if ([[ ${+_lists} -eq 0 ]] || _cache_invalid LISTS) && ! _retrieve_cache LISTS; then
5+
_lists=($(reminders show-lists 2> /dev/null))
6+
_store_cache LISTS _lists
7+
fi
8+
9+
echo $_lists
10+
}
11+
12+
_reminders_show-lists() {
13+
_message "show all reminders lists"
14+
}
15+
16+
_reminders_show() {
17+
if [[ ${#words[@]} -eq 2 ]]; then
18+
lists=($(_get_lists))
19+
if [[ $lists != "" ]]; then
20+
_values "lists" $lists
21+
fi
22+
fi
23+
}
24+
25+
_reminders_complete() {
26+
if [[ ${#words[@]} -eq 2 ]]; then
27+
lists=($(_get_lists))
28+
if [[ $lists != "" ]]; then
29+
_values "lists" $lists
30+
fi
31+
elif [[ ${#words[@]} -gt 2 ]]; then
32+
_message "reminder index"
33+
fi
34+
}
35+
36+
_reminders_add() {
37+
if [[ ${#words[@]} -eq 2 ]]; then
38+
lists=($(_get_lists))
39+
if [[ $lists != "" ]]; then
40+
_values "lists" $lists
41+
fi
42+
elif [[ ${#words[@]} -gt 2 ]]; then
43+
_message "reminder content"
44+
fi
45+
}
46+
47+
if (( CURRENT > 2 )); then
48+
(( CURRENT-- ))
49+
shift words
50+
_call_function - _reminders_${words[1]}
51+
return
52+
else
53+
local -a _reminders_subcommands
54+
_reminders_subcommands=(
55+
'show-lists:show all reminders lists'
56+
'show:show the reminders on a list'
57+
'complete:complete a specific reminder on a list'
58+
'add:add a new reminder on a list'
59+
)
60+
_describe -t commands 'reminders subcommands' _reminders_subcommands && ret=0
61+
fi
62+
63+
# vim:ft=zsh:ts=2

0 commit comments

Comments
 (0)