Parent directory

_dnote

814 bytes
 1#compdef dnote
 2
 3local -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
18get_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
29if (( CURRENT == 2 )); then
30  _describe -t commands "dnote subcommand" _1st_arguments
31  return
32elif (( CURRENT == 3 )); then
33  case "$words[2]" in
34    v|view|a|add)
35      _alternative \
36        "names:book names:($(get_booknames))"
37  esac
38fi
39