Skip to content

Commit

Permalink
Merge branch 'description'
Browse files Browse the repository at this point in the history
Conflicts:
	todo.sh
  • Loading branch information
trajano committed Feb 10, 2011
2 parents 07ac4f3 + 7fb9761 commit 5afdf74
Showing 1 changed file with 49 additions and 40 deletions.
89 changes: 49 additions & 40 deletions todo.sh
Expand Up @@ -945,46 +945,55 @@ case $action in
fi
else
echo "$item is already marked done"
fi
done

if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
archive
fi
;;

"describe" )
# Finds the first parameter in $TODO_DESC using
# the pattern where you search from the beginning
# If it finds it, remove the value
# Add the new value to the file
# Sort the file and save it again
# TODO add error handling
errmsg="usage: $TODO_SH describe [^TAG|+PROJECT|@CONTEXT] \"DESCRIPTION\""

shift
category=`echo "$1" | tr 'A-Z' 'a-z'`

# TODO error if the first character of $catgory is not ^+@

shift
input="$category $*"

# escape potential bad regexp characters
# TODO convert the escape into a function
key="$category"
escapekey $key
if grep -q "^$key " "$DESC_FILE"
then
# Found an existing category value, so just
# remove it because we are replacing it with
# a new one
grep -v "^$key" "$DESC_FILE" > "$TMP_FILE"
cat $TMP_FILE > $DESC_FILE
fi
_addto "$DESC_FILE" "$input"
;;

fi
done

if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
archive
fi
;;

"describe" )
# Finds the first parameter in $TODO_DESC using
# the pattern where you search from the beginning
# If it finds it, remove the value
# Add the new value to the file
# Sort the file and save it again
# TODO add error handling
errmsg="usage: $TODO_SH describe [^TAG|+PROJECT|@CONTEXT] \"DESCRIPTION\""

shift

[ "$#" -eq 0 ] && die "$errmsg"
category=$1

# TODO error if the first character of $catgory is not ^+@
if echo $category | grep -q '^[+@^]'
then
true
else
die "$errmsg"
fi

shift
[ "$#" -eq 0 ] && die "$errmsg"
input="$category $*"

# escape potential bad regexp characters
# TODO convert the escape into a function
key="$category"
escapekey $key
if grep -q "^$key " "$DESC_FILE"
then
# Found an existing category value, so just
# remove it because we are replacing it with
# a new one
grep -v "^$key" "$DESC_FILE" > "$TMP_FILE"
cat $TMP_FILE > $DESC_FILE
fi
_addto "$DESC_FILE" "$input"
;;

"edit" )
errmsg="usage: $TODO_SH edit [ITEM#]"
# shift so we get arguments to the do request
Expand Down

0 comments on commit 5afdf74

Please sign in to comment.