mirror of
https://github.com/dnote/dnote
synced 2026-03-18 00:09:56 +01:00
Improve package structure (#207)
* Improve package structure * Set up travis
This commit is contained in:
parent
ca03c8576a
commit
23a511dbe0
171 changed files with 4750 additions and 4531 deletions
|
|
@ -1,48 +0,0 @@
|
|||
#/usr/bin/env bash
|
||||
__dnote_debug()
|
||||
{
|
||||
if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then
|
||||
echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
# commands are the valid commands
|
||||
commands=("add" "view" "edit" "remove" "find" "sync" "login" "logout" "help" "version")
|
||||
|
||||
_complete_root_command() {
|
||||
COMPREPLY=($(compgen -W "${commands[*]}" "${current_word}"))
|
||||
}
|
||||
|
||||
_complete_view_command() {
|
||||
names=$(dnote view --name-only)
|
||||
query=${COMP_WORDS[*]:2}
|
||||
|
||||
__dnote_debug "${FUNCNAME[0]} query: ${query}"
|
||||
|
||||
while read -r line; do
|
||||
if [[ ${line} == *"${query}"* ]]; then
|
||||
COMPREPLY+=("${line}")
|
||||
fi
|
||||
done <<< "$names"
|
||||
}
|
||||
|
||||
_dnote_completions() {
|
||||
local current_word="${COMP_WORDS[${COMP_CWORD}]}"
|
||||
|
||||
__dnote_debug "COMP_WORDS: ${COMP_WORDS[*]} COMP_CWORD: ${COMP_CWORD} current_word: ${current_word}"
|
||||
|
||||
if [[ "${COMP_CWORD}" -eq 1 ]]; then
|
||||
_complete_root_command
|
||||
elif [[ "${COMP_CWORD}" -ge 2 ]]; then
|
||||
cmd=${COMP_WORDS[1]}
|
||||
|
||||
__dnote_debug "cmd: ${cmd}"
|
||||
|
||||
if [[ ( "${cmd}" == view ) || ( "${cmd}" == v ) || ( "${cmd}" == add ) || ( "${cmd}" == a ) ]]; then
|
||||
_complete_view_command
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
complete -F _dnote_completions dnote
|
||||
Loading…
Add table
Add a link
Reference in a new issue