diff options
author | Sung Won Cho <hello@sung.io> | 2019-06-16 03:52:22 +1000 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2019-06-15 10:52:22 -0700 |
commit | 5f18dbf895675ff22dcbe2afa78b72b74350ea58 (patch) | |
tree | dc9e9a14dac39e5bc84abdf619fd31c8c337a74b /plugins/dnote/_dnote | |
parent | 36e13f4803f2fef7d7ba3109cb0bd913de78cfea (diff) | |
download | zsh-5f18dbf895675ff22dcbe2afa78b72b74350ea58.tar.gz zsh-5f18dbf895675ff22dcbe2afa78b72b74350ea58.tar.bz2 zsh-5f18dbf895675ff22dcbe2afa78b72b74350ea58.zip |
Add a completion plugin for dnote (#7885)
Diffstat (limited to 'plugins/dnote/_dnote')
-rw-r--r-- | plugins/dnote/_dnote | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/dnote/_dnote b/plugins/dnote/_dnote new file mode 100644 index 000000000..c8b33486a --- /dev/null +++ b/plugins/dnote/_dnote @@ -0,0 +1,39 @@ +#compdef dnote + +local -a _1st_arguments + +_1st_arguments=( + 'add:add a new note' + 'view:list books, notes, or view a content' + 'edit:edit a note or a book' + 'remove:remove a note or a book' + 'find:find notes by keywords' + 'sync:sync data with the server' + 'login:login to the dnote server' + 'logout:logout from the dnote server' + 'version:print the current version' + 'help:get help about any command' +) + +get_booknames() { + local names=$(dnote view --name-only) + local -a ret + + while read -r line; do + ret+=("${line}") + done <<< "$names" + + echo "$ret" +} + +if (( CURRENT == 2 )); then + _describe -t commands "dnote subcommand" _1st_arguments + return +elif (( CURRENT == 3 )); then + case "$words[2]" in + v|view|a|add) + _alternative \ + "names:book names:($(get_booknames))" + esac +fi + |