aboutsummaryrefslogtreecommitdiff
path: root/src/dmtool.bash
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-05-06 14:13:28 -0400
committerYour Name <you@example.com>2021-05-06 14:13:28 -0400
commit9f3802690f9dd9452e96d1d7a879291978d66e35 (patch)
tree6d6c17b39abdb9490119241bc4fc061744b46d7d /src/dmtool.bash
parent2a9f262e6db5906db445d465e500d7ba8c90fab3 (diff)
downloaddmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.tar.gz
dmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.tar.bz2
dmtool-9f3802690f9dd9452e96d1d7a879291978d66e35.zip
Refactoring
Diffstat (limited to 'src/dmtool.bash')
-rw-r--r--src/dmtool.bash97
1 files changed, 71 insertions, 26 deletions
diff --git a/src/dmtool.bash b/src/dmtool.bash
index 41f70e9..ffc75f7 100644
--- a/src/dmtool.bash
+++ b/src/dmtool.bash
@@ -60,35 +60,80 @@ _dmtool_complete_entries () {
fi
}
+_dmtool_skills()
+{
+ echo -e "athletics\nacrobatics\nstealth\narcana\nhistory\ninvestigation\nnature\nreligion\ninsight\nmedicine\nperception\nsurvival\ndeception\nintimidation\nperformance\npersuasion\nsleight of hand\nanimal handling"
+}
+
+_dmtool_abilities()
+{
+ echo -e "str\ndex\ncon\nint\nwis\ncha"
+}
+
+_dmtool_complete_skills_abilities()
+{
+ local IFS=$'\n'
+ COMPREPLY+=($(compgen -W "$(_dmtool_skills)" -- ${cur}))
+ COMPREPLY+=($(compgen -W "$(_dmtool_abilities)" -- ${cur}))
+}
+
_dmtool()
{
- COMPREPLY=()
- local cur="${COMP_WORDS[COMP_CWORD]}"
- local commands="ls cp mkdir mv rm roll damage heal reset set help"
- if [[ $COMP_CWORD -gt 1 ]]; then
- local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
- case "${COMP_WORDS[1]}" in
- ls|mkdir|rm|reset)
- _dmtool_complete_entries
- ;;
- cp|mv)
- if [[ $COMP_CWORD -le 3 ]]; then
- _dmtool_complete_entries
+ COMPREPLY=()
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ local commands="ls cp mkdir mv rm attacks roll damage heal reset set edit add del help"
+ if [[ $COMP_CWORD -gt 1 ]]; then
+ local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
+ case "${COMP_WORDS[1]}" in
+ ls|mkdir|rm|reset)
+ _dmtool_complete_entries
+ ;;
+ cp|mv|add)
+ if [[ $COMP_CWORD -le 3 ]]; then
+ _dmtool_complete_entries
+ fi
+ ;;
+ attacks|roll|damage|heal|set|edit|del)
+ if [[ $COMP_CWORD -le 2 ]]; then
+ _dmtool_complete_entries
+ else
+ case "${COMP_WORDS[1]}" in
+ roll)
+ _dmtool_complete_skills_abilities
+ # Add in attacks
+ local IFS=$'\n'
+ opts="$(${COMP_WORDS[0]} attacks ${COMP_WORDS[2]})"
+ COMPREPLY+=($(compgen -W "$opts" -- ${cur}))
+ ;;
+ damage)
+ COMPREPLY+=($(compgen -W "--magical -m --silvered -s --adamantine -a" -- ${cur}))
+ if [[ $COMP_CWORD -eq 4 ]]; then
+ COMPREPLY+=($(compgen -W "slashing piercing bludgeoning poison acid fire cold radiant necrotic lightning thunder force psychic" -- ${cur}))
+ fi
+ ;;
+ set)
+ if [[ $COMP_CWORD -eq 3 ]]; then
+ _dmtool_complete_skills_abilities
+ COMPREPLY+=($(compgen -W "proficiency name" -- ${cur}))
+ elif [[ $COMP_CWORD -eq 4 ]]; then
+ local skills="$(_dmtool_skills)"
+ if [[ "$skills" =~ "$lastarg" ]]; then
+ COMPREPLY+=($(compgen -W "none proficient expert" -- ${cur}))
fi
- ;;
- roll|damage|heal|set|add)
- if [[ $COMP_CWORD -le 2 ]]; then
- _dmtool_complete_entries
- else
- # Other various stuff
- :
- fi
- ;;
- esac
- else
- COMPREPLY+=($(compgen -W "${commands}" -- ${cur}))
- _dmtool_complete_entries 1
- fi
+ fi
+ ;;
+ del)
+ #TODO: Add items and spells
+ _dmtool_complete_skills_abilities
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ else
+ COMPREPLY+=($(compgen -W "${commands}" -- ${cur}))
+ _dmtool_complete_entries 1
+ fi
}
complete -o filenames -F _dmtool dmtool