Skip to content

Commit

Permalink
Add zsh completions
Browse files Browse the repository at this point in the history
  • Loading branch information
keith committed Sep 19, 2016
1 parent 80179d5 commit 869192d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARCHIVE=$(EXECUTABLE).tar.gz
SRC=$(wildcard Sources/*.swift)

clean:
rm -f $(EXECUTABLE) $(ARCHIVE)
rm -f $(EXECUTABLE) $(ARCHIVE) _reminders
swift build --clean

build: $(SRC)
Expand All @@ -19,10 +19,11 @@ release: clean
-Xswiftc -static-stdlib

package: release
tar -pvczf $(ARCHIVE) -C $(RELEASE_BUILD) $(EXECUTABLE)
tar -pvczf $(ARCHIVE) -C zsh _reminders -C ../$(RELEASE_BUILD) $(EXECUTABLE)
tar -zxvf $(ARCHIVE)
@shasum -a 256 $(ARCHIVE)
@shasum -a 256 $(EXECUTABLE)
rm $(EXECUTABLE) _reminders

install: release
install $(RELEASE_BUILD)/$(EXECUTABLE) $(PREFIX)
Expand Down
63 changes: 63 additions & 0 deletions zsh/_reminders
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#compdef reminders

_get_lists() {
if ([[ ${+_lists} -eq 0 ]] || _cache_invalid LISTS) && ! _retrieve_cache LISTS; then
_lists=($(reminders show-lists 2> /dev/null))
_store_cache LISTS _lists
fi

echo $_lists
}

_reminders_show-lists() {
_message "show all reminders lists"
}

_reminders_show() {
if [[ ${#words[@]} -eq 2 ]]; then
lists=($(_get_lists))
if [[ $lists != "" ]]; then
_values "lists" $lists
fi
fi
}

_reminders_complete() {
if [[ ${#words[@]} -eq 2 ]]; then
lists=($(_get_lists))
if [[ $lists != "" ]]; then
_values "lists" $lists
fi
elif [[ ${#words[@]} -gt 2 ]]; then
_message "reminder index"
fi
}

_reminders_add() {
if [[ ${#words[@]} -eq 2 ]]; then
lists=($(_get_lists))
if [[ $lists != "" ]]; then
_values "lists" $lists
fi
elif [[ ${#words[@]} -gt 2 ]]; then
_message "reminder content"
fi
}

if (( CURRENT > 2 )); then
(( CURRENT-- ))
shift words
_call_function - _reminders_${words[1]}
return
else
local -a _reminders_subcommands
_reminders_subcommands=(
'show-lists:show all reminders lists'
'show:show the reminders on a list'
'complete:complete a specific reminder on a list'
'add:add a new reminder on a list'
)
_describe -t commands 'reminders subcommands' _reminders_subcommands && ret=0
fi

# vim:ft=zsh:ts=2

0 comments on commit 869192d

Please sign in to comment.