1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

unposted: more todo.sh commands

This commit is contained in:
Peter Stephenson 2010-08-19 16:08:30 +00:00
parent ef9b4ad79e
commit 49af8cc847

View file

@ -29,17 +29,30 @@ _arguments -s -n : \
local projmsg="context or project" local projmsg="context or project"
local txtmsg="text with contexts or projects" local txtmsg="text with contexts or projects"
# Skip "command" as command prefix if words after
if [[ $words[NORMARG] == command && NORMARG -lt CURRENT ]]; then
(( NORMARG++ ))
fi
case $state in case $state in
(commands) (commands)
cmdlist=( cmdlist=(
"add:add TODO ITEM to todo.txt." "add:add TODO ITEM to todo.txt."
"addm:add TODO ITEMs, one per line, to todo.txt."
"addto:add text to file (not item)"
"append:adds to item on line NUMBER the text TEXT." "append:adds to item on line NUMBER the text TEXT."
"archive:moves done items from todo.txt to done.txt." "archive:moves done items from todo.txt to done.txt."
"command:run internal commands only"
"del:deletes the item on line NUMBER in todo.txt." "del:deletes the item on line NUMBER in todo.txt."
"depri:remove prioritization from item"
"do:marks item on line NUMBER as done in todo.txt." "do:marks item on line NUMBER as done in todo.txt."
"help:display help"
"list:displays all todo items containing TERM(s), sorted by priority." "list:displays all todo items containing TERM(s), sorted by priority."
"listall:displays items including done ones containing TERM(s)" "listall:displays items including done ones containing TERM(s)"
"listcon:list all contexts"
"listfile:display all files in .todo directory"
"listpri:displays all items prioritized at PRIORITY." "listpri:displays all items prioritized at PRIORITY."
"move:move item between files"
"prepend:adds to the beginning of the item on line NUMBER text TEXT." "prepend:adds to the beginning of the item on line NUMBER text TEXT."
"pri:adds or replace in NUMBER the priority PRIORITY (upper case letter)." "pri:adds or replace in NUMBER the priority PRIORITY (upper case letter)."
"replace:replace in NUMBER the TEXT." "replace:replace in NUMBER the TEXT."
@ -51,10 +64,9 @@ case $state in
(arguments) (arguments)
case $words[NORMARG] in case $words[NORMARG] in
(append|del|do|prepend|pri|replace) (append|command|del|move|mv|prepend|pri|replace|rm)
if (( NORMARG == CURRENT - 1 )); then if (( NORMARG == CURRENT - 1 )); then
itemlist=(${${(M)${(f)"$(todo.sh -p list | sed '/^--/,$d')"}##<-> *}/(#b)(<->) (*)/${match[1]}:${match[2]}}) nextstate=item
_describe -t todo-items 'todo item' itemlist
else else
case $words[NORMARG] in case $words[NORMARG] in
(pri) (pri)
@ -63,6 +75,9 @@ case $state in
(append|prepend) (append|prepend)
nextstate=proj nextstate=proj
;; ;;
(move|mv)
nextstate=file
;;
(replace) (replace)
item=${words[CURRENT-1]##0##} item=${words[CURRENT-1]##0##}
compadd -Q -- "${(qq)$(todo.sh -p list "^[ 0]*$item " | sed '/^--/,$d')##<-> (\([A-Z]\) |)}" compadd -Q -- "${(qq)$(todo.sh -p list "^[ 0]*$item " | sed '/^--/,$d')##<-> (\([A-Z]\) |)}"
@ -71,11 +86,31 @@ case $state in
fi fi
;; ;;
(add|list|listall) (depri|do|dp)
nextstate=item
;;
(a|add|addm|list|ls|listall|lsa)
nextstate=proj nextstate=proj
;; ;;
(listpri) (addto)
if (( NORMARG == CURRENT - 1 )); then
nextstate=file
else
nexstate=proj
fi
;;
(listfile|lf)
if (( NORMARG == CURRENT -1 )); then
nextstate=file
else
_message "Term to search file for"
fi
;;
(listpri|lsp)
nextstate=pri nextstate=pri
;; ;;
@ -87,6 +122,15 @@ case $state in
esac esac
case $nextstate in case $nextstate in
(file)
_path_files -W ~/.todo
;;
(item)
itemlist=(${${(M)${(f)"$(todo.sh -p list | sed '/^--/,$d')"}##<-> *}/(#b)(<->) (*)/${match[1]}:${match[2]}})
_describe -t todo-items 'todo item' itemlist
;;
(pri) (pri)
if [[ $words[CURRENT] = (|[A-Z]) ]]; then if [[ $words[CURRENT] = (|[A-Z]) ]]; then
if [[ $words[CURRENT] = (|Z) ]]; then if [[ $words[CURRENT] = (|Z) ]]; then