]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/dnote/_dnote
c8b33486a370e9db3412605589e1a6267bd9188c
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / dnote / _dnote
1 #compdef dnote
2
3 local -a _1st_arguments
4
5 _1st_arguments=(
6   'add:add a new note'
7   'view:list books, notes, or view a content'
8   'edit:edit a note or a book'
9   'remove:remove a note or a book'
10   'find:find notes by keywords'
11   'sync:sync data with the server'
12   'login:login to the dnote server'
13   'logout:logout from the dnote server'
14   'version:print the current version'
15   'help:get help about any command'
16 )
17
18 get_booknames() {
19   local names=$(dnote view --name-only)
20   local -a ret
21
22   while read -r line; do
23     ret+=("${line}")
24   done <<< "$names"
25
26   echo "$ret"
27 }
28
29 if (( CURRENT == 2 )); then
30   _describe -t commands "dnote subcommand" _1st_arguments
31   return
32 elif (( CURRENT == 3 )); then
33   case "$words[2]" in
34     v|view|a|add)
35       _alternative \
36         "names:book names:($(get_booknames))"
37   esac
38 fi
39