ohmyzsh/plugins/taskman/_taskman
2025-06-13 15:37:10 +08:00

69 lines
2.2 KiB
Text

#compdef tasks tm task todo
# Terminal Task Manager completion for Oh-My-Zsh
# Provides tab completion for all task management commands
_taskman() {
local context state state_descr line
typeset -A opt_args
_arguments -C \
'1:command:->commands' \
'*::arg:->args' && return 0
case $state in
commands)
local -a commands
commands=(
'ui:Launch interactive UI'
'show:Launch interactive UI'
'add:Add new task'
'new:Add new task'
'create:Add new task'
'list:List tasks'
'ls:List tasks'
'done:Mark task as completed'
'complete:Mark task as completed'
'delete:Delete a task'
'del:Delete a task'
'rm:Delete a task'
'help:Show help'
)
_describe 'taskman commands' commands
;;
args)
case $line[1] in
add|new|create)
_arguments \
'1:task description:' \
'2:priority:(high normal low)'
;;
list|ls)
_arguments \
'1:filter:(all pending completed)'
;;
done|complete|delete|del|rm)
# Complete with task IDs if possible
if command -v python3 >/dev/null 2>&1; then
local plugin_dir="${0:h}"
local -a task_ids
# Try to get task IDs from the CLI
task_ids=($(python3 "$plugin_dir/bin/task_cli.py" list all 2>/dev/null | grep -o '(ID: [0-9]\+)' | grep -o '[0-9]\+' 2>/dev/null))
if [[ ${#task_ids[@]} -gt 0 ]]; then
_describe 'task IDs' task_ids
else
_message 'task ID'
fi
else
_message 'task ID'
fi
;;
esac
;;
esac
}
_taskman