autocompletion
Autocompletion of book names
$ dnote v j<hit tab>
$ dnote v javascript<hit tab>
$ dnote v js
# ...
This is a bit tricky as this depends on the shell you want to provide autocompletions for. Bash and zsh sound like a good place to start, but I'm not 100% how things work on Windows.
@sungwoncho - is Windows within scope for this issue? I can help with the zsh and bash completion scripts, but have no experience with Windows.
I think zsh and bash is a good place to start.
I have implemented bash and zsh completion in #193 and opened a PR to include it in oh-my-zsh https://github.com/robbyrussell/oh-my-zsh/pull/7885.
If you have any suggestions on how we can make the autocompletion available and just work, please let me know. I'm thinking maybe installation script should place the autocompletion scripts in appropriate places but that might require sudo.
On bash, I'm using this:
/usr/local/etc/bash_completion.d/dnote
# bash completion for dnote
have dnote &&
_dnote()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
v|view|a|add)
COMPREPLY=( $( compgen -W '$(dnote view --name-only)' -- "$cur" ) )
return 0
;;
esac
COMPREPLY=( $( compgen -W '$( dnote -h | grep "^ *[a-z]\+" -o )' -- "$cur"))
} && complete -F _dnote dnote
This has been implemented.
- Bash: https://github.com/dnote/dnote/blob/b47c792d5fcf610db103ab49c57862e49333e13f/pkg/cli/dnote-completion.bash
- Zsh: https://github.com/dnote/dnote/blob/b47c792d5fcf610db103ab49c57862e49333e13f/pkg/cli/dnote-completion.zsh
- Documentation: https://github.com/dnote/dnote/wiki/Dnote-CLI#auto-completion
Also, oh-my-zsh comes with Dnote auto-completion plugin directly.