Commit Graph

171 Commits

Author SHA1 Message Date
Philippe Teuwen
cace5eb2d9 Bugfix: TODOTXT_DEFAULT_ACTION was not exported, now exports TODOTXT_*
Simplify the export of TODOTXT variables by having bash construct
the export list dynamically.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-25 20:27:59 -04:00
Philippe Teuwen
678283b69e Bugfix: typo in addto help msg skipped name of command
Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-20 10:04:45 -04:00
Dave Hein
a67d0de625 Add TODOTXT_FINAL_FILTER to provide a final custom list filter.
The idea behind this is to allow a config file or addon to inject
a list output filter after all the other filtering has been
performed. The existing TODOTXT_SORT_COMMAND provides a hook
for a custom filter prior to colorization and priority/context/proj
hiding; this new TODOTXT_FINAL_FILTER provides a hook for custom
filtering after the colorization and pri/con/proj hiding.

(I found this hook was needed when I wanted to trim the output to a
maximum line length.)

Note: I've added a number of tests of the list command, including
one for this new variable, as part of this change.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-19 20:30:53 -04:00
Philippe Teuwen
55015f5071 Bugfix: support commands combination for TODOTXT_SORT_COMMAND
So now e.g. piped commands can be used:
export TODOTXT_SORT_COMMAND=" env LC_COLLATE=C sort -f -k2 - | grep -m 10 ."
2009-04-19 20:30:53 -04:00
Emil Sit
fee3133547 Uniformly use $TODO_SH to refer to script.
Set $TODO_SH to just be $(basename "$0") at the beginning
of the script and use it in all usage messages.

This happens to simplify testing because it allows us to refer to
the script as "todo.sh" in all output.  For general use, if the
user has aliased to file to something else, the usage messages will
still reflect that alias.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-18 21:26:42 -04:00
Philippe Teuwen
4d3b7472ff Bugfix: pri accepted priorities of more than a single letter
e.g. todo.sh pri 1 aa

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-11 08:20:15 +08:00
Emil Sit
477738828f Don't set colors in default todo.cfg.
Users are probably unlikely to change the definition
of colors like $BLACK so just define them in todo.sh
and comment them out in todo.cfg.  Similarly, leave
default values for priority coloring available but
commented out.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-07 20:34:10 -04:00
Philippe Teuwen
b9f95633dc Cleanup: removing annoying trailing space on pri tasks
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-08 07:44:41 +08:00
Philippe Teuwen
df1e2eb7cf Cleanup: del/depri/pri: some more $2 -> $item
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-08 07:36:20 +08:00
Philippe Teuwen
a4e68f9c3f Bugfix: handling of priorities in pri/depri/do: no more globbing
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-08 07:36:02 +08:00
Gina Trapani
3028de42a8 Bugfix, take 2: depri no longer wipes out entire task with other parens http://tech.groups.yahoo.com/group/todotxt/message/1828 2009-04-07 10:32:16 -07:00
Gina Trapani
8fceae171d Bugfix: depri no longer wipes out entire task with other parens http://tech.groups.yahoo.com/group/todotxt/message/1828 2009-04-07 10:24:06 -07:00
Dave Hein
9898e7df3f Fix misplaced quote that was blocking filename globbing in the action
'usage' logic.

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-08 00:12:08 +08:00
Dave Hein
42e1a658d6 Add quotes around $action to handle cases where todo.actions.d path includes embedded spaces.
There were a couple places where $action was used without quotes
that caused a problem if the .todo.actions.d had a parent directory
path that included spaces (e.g. /cygdrive/c/Documents\ and\ Settings/jo-user).
This was in the section that calls the addons with the 'usage' arg.

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-08 00:11:49 +08:00
Philippe Teuwen
f1caecec4e TODO_ACTIONS_D is now TODO_ACTIONS_DIR
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-07 03:34:33 +08:00
Philippe Teuwen
078c69496f Parametrize .todo.actions.d location
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-07 03:34:01 +08:00
Gina Trapani
8567a90e4c Bugfix: Replace echoes old todo before new todo. 2009-04-05 10:49:06 -07:00
U-STARBUCK\gina
d860c2c36e Converted tab to spaces 2009-04-04 12:18:57 -07:00
U-STARBUCK\gina
8e864568a9 Allow custom sort (tx edgewood) 2009-04-02 22:47:50 -07:00
Emil Sit
df4f9150cf Remove gawk and uniq dependencies for listcon, listproj.
Implement listcon and listproj in terms of grep -w -o, which prints
words that match the given regular expression, and sort -u, which
obviates uniq.  This probably only works with GNU grep, which seems
better than having to rely on gawk (which is used nowhere else).

Signed-off-by: Emil Sit <sit@emilsit.net>

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-03 13:32:20 +08:00
Emil Sit
5cc988102d Misc. whitespace cleanups.
Single space after colon.
No end-of-line whitespace.
Replace tabs with whitespace.

Signed-off-by: Emil Sit <sit@emilsit.net>

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-03 13:32:20 +08:00
U-STARBUCK\gina
1a6ff81e28 Makefile infrastructure 2009-04-02 21:01:44 -07:00
Emil Sit
0b3d9109de todo.sh: Generate version info at dist time.
When generating the distribution files, prepare todo.sh
by subbing in the current version so that users will
get a proper version number.

Tries to detect VERSION-FILE for running from
the development directory but this doesn't work well
when $PWD is not the top of the git repo.

Signed-off-by: Emil Sit <sit@emilsit.net>
2009-04-02 21:05:58 -04:00
Emil Sit
31216fe365 _list: Fix line/item counting, accounting for blank lines.
If a file had blank lines or was totally empty, _list would
result in an in-correct count of total items (either "" or
the number of lines, instead of the number of items).  This
commit splits the filtering into three phases: line numbering,
filtering (optional), and post-processing, and then does
counting separately, if desired.

Signed-off-by: Emil Sit <sit@emilsit.net>

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-04-03 07:42:43 +08:00
Emil Sit
7f5c8fb3e1 Add a short help message to be called for -h.
Put the old help message under a "help" command.  The
short help message just lists the available commands and
should fit on a single screen.

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-03-21 07:20:35 +08:00
Emil Sit
3e7b60abcd Factor out common usage message text.
Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-03-21 07:20:29 +08:00
Emil Sit
cc3e5f73aa _list: Add in an extra filter to remove empty lines.
The rewrite of ls functionality may have allowed blank but numbered
lines to creep into the ls display.  Search for such lines and
exclude them.

Signed-off-by: Emil Sit <sit@emilsit.net>

Signed-off-by: Gina Trapani <ginatrapani@gmail.com>
2009-03-21 07:20:28 +08:00
Gina Trapani
52604ebf78 Tweaked version and contributor details 2009-03-19 18:52:47 -07:00
David A. Harding
758cdc5551 Merge branch 'gina/master' 2009-03-19 07:10:09 -04:00
David A. Harding
02dc030225 Putting Quotes Around $TODO_TMP
Suggested by Gina.
2009-03-19 07:06:07 -04:00
David A. Harding
7b769b2eea s/[A-Z]/[[:upper:]]/ 2009-03-17 19:15:27 -04:00
David A. Harding
39ee9ab045 Added -vv For Debugging Output 2009-03-17 14:07:48 -04:00
David A. Harding
07bb979d43 Move Filter Command Up & Remove Extra Sort Command 2009-03-14 15:06:53 -04:00
Ed Blackman
7e04849a4f Move filter before priority text changes, so filter doesn't match invisible text 2009-03-14 13:39:27 -04:00
David A. Harding
f8b2646b92 Don't Echo Empty Lines & Streamline Sed wc -l Syntax 2009-03-14 09:35:10 -04:00
Ed Blackman
02980ae7ee Fix "post_hilter_command" typo 2009-03-14 01:18:42 -04:00
Ed Blackman
12bbf8fe67 Fix spacing (tabs to spaces) 2009-03-14 01:17:46 -04:00
Ed Blackman
ab78607506 Use sed line counting to replace 'wc -l' 2009-03-14 01:15:52 -04:00
David A. Harding
6be78ca5fa Added Exclusion Syntax by Jacobo de Vera
-keyword or -"key phrase" should exclude those terms from the output.
2009-03-13 22:21:48 -04:00
Ed Blackman
9ab77253db Implement pre and post filters in _list 2009-03-13 18:17:16 -04:00
Ed Blackman
cf3c5312bf Export _list for call by extensions 2009-03-13 17:02:31 -04:00
Ed Blackman
37a7bb0e8a Use relative rather than absolute filename in status message 2009-03-13 16:40:55 -04:00
Ed Blackman
ed8e8e24d9 Consistent spacing for \ continuation in _list 2009-03-13 16:34:25 -04:00
David A. Harding
d6f00ca42f Minor formatting and comments changes 2009-03-13 12:14:08 -04:00
David A. Harding
a03a3bf66b Fixed Windows Regression, New _list Function
Commit f55f5e8b5f introduced a known regression on Windows that
prevented users from using configuration files starting with C:\.  The
following logic fixes this:
    +    ## If the file starts with a "/" use absolute path. Otherwise,
    +    ## try to find it in either $TODO_DIR or using a relative path
    +    if [ "${1:0:1}" == / ]
    +    then
    +        ## Absolute path
    +        src="$FILE"
    +    elif [ -f "$TODO_DIR/$FILE" ]
    +    then
    +        ## Path relative to todo.sh directory
    +        src="$TODO_DIR/$1"
    +    elif [ -f "$FILE" ]
    +    then
    +       ## Path relative to current working directory
    +       src="$FILE"
    +    else
    +        echo "TODO: File $FILE does not exist."
    +       exit 1
    +    fi

New _list function takes a filename and a list of search expressions.
We no longer use exec to call ourselves recursively.
2009-03-13 11:59:03 -04:00
David A. Harding
448cecb91d Simplify and Reused Code to Print ls Summary Line 2009-03-13 11:00:34 -04:00
David A. Harding
ee59233c36 Replaced Grep Loop, Fixed Sed Bug, Some Small Changes
Implemented several suggestions by Jacobo de Vera:

    > 1. [lines 539-551]: [...] replace the for loop with simply this:
    >    PADDING=${#LINES}

    > 2. [line 558]: As the script now supports a 6 digit number of tasks,
    > the first substitution should add 5 spaces instead of 2

    > 3. [lines 606-613]: The first search item is processed before the for
    >    loop, and the loop does the same for the rest. Wouldn't making this
    >    more general make the code more readable?

The changes for suggestion #3 let me add a new feature: when VERBOSE is
enabled, the summary line prints more info -- and it prints it on every
run:

    $ todo.sh ls "buy a"
    34 Buy a portable gas can @errands +safe
    --
    TODO: 1 of 49 tasks shown from /home/harding/var/git/todo/todo.txt

Also, generalizing and centralizing the code added a small but
measurable speed increase.

No new known regressions were introduced.
2009-03-12 22:23:59 -04:00
David A. Harding
f55f5e8b5f Make ls-Family Actions Use Listfile Backend
Essentially,

    ls)
	shift
	exec "$TODO_SH" listfile "$TODO_FILE" "$@"
	;;
    lsa)
	shift
	cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
	exec $TODO_SH listfile "$TMP_FILE" "$@"
	;;
    lsp)
	shift ## was "listpri"
	shift ## was priority
	exec $TODO_SH listfile "$TODO_FILE" "$pri" "$@"
	;;;

Also adds the following features:

    1. Numbers are padded with up to five zeros (but only the minimum
       necessary), letting you list up to 999,999 tasks with the same
       formatting.

    2. All ls-family commands hide context, priority, and project when
       the user sets those hide options.

    3. Quoted arguments are passed on to grep as whole arguments,
       enabling the following:

	$ todo.sh ls buy a | head -n2
	34 Buy a portable gas can
	22 Buy door

	$ todo.sh ls "buy a"
	34 Buy a portable gas can

    4. listfile can take an absolute path. Any filename starting with a
       "/" will be treated as an absolute path; any other filename will
       be treated as relative to $TODO_DIR. Since a leading "/" would be
       striped by the operating system anyway under the old code, this
       is fully backward compatible.

Contains the following regressions:

    1. The ls verbose line count messages are more generic.

    2. There is no verbose line count line for lspri.

    3. I don't think listfile's absolute path feature will work on
       Windows. If it doesn't, either this patch needs to be thrown
       away, listall needs to be rewritten, or (my preference) $TMP_FILE
       needs to set as relative to $TODO_DIR.
2009-03-12 11:52:28 -04:00
David A. Harding
d508ed9dee Modularized Listing Sed
Still more to do tomorrow.
2009-03-12 01:02:10 -04:00
Matt Brubeck
62f3313ff9 Merge branch 'master' of git://github.com/ginatrapani/todo.txt-cli 2009-03-11 16:22:27 -07:00