diff options
Diffstat (limited to 'src/dmtool.bash')
-rw-r--r-- | src/dmtool.bash | 97 |
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 |