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>
add/list and replace are already covered by existing tests.
Add a new test, t1200-pri.sh, that handles the priority tests.
Signed-off-by: Emil Sit <sit@emilsit.net>
* 'test-framework' of git://github.com/sit/todo.txt-cli:
tests: Update documentation to reflect recent changes.
tests: add testshell.sh and port old testsuite.txt
tests: Explicitly control the date for todo.sh.
tests: Make test writing simpler and add two new tests.
Merge Phil's README_generate-test into the main README
and also update the test library documentation to reflect
test_todo_session and test_tick.
Signed-off-by: Emil Sit <sit@emilsit.net>
Add a simple helper script testshell.sh that can be called
to set up an environment for generating test case transcripts
that can then be pasted into an actual test script.
Port old testsuite.txt into t9999-testsuite_example.sh
with the aim of refactoring it later into smaller tests.
Also, change test_todo_session to count from one instead of zero when
autogenerating tests.
Signed-off-by: Emil Sit <sit@emilsit.net>
Create a custom date view for todo.sh tests -- the time
is set in TODO_TEST_TIME as seconds since the Unix epoch
and a custom wrapper in the testing directory is put at the
front of the path to intercept todo.sh calls to date for
date formatting.
This will only work as long as todo.sh calls $(date) for
date formatting. It also assumes a date command that
supports the -d flag (such as the one in GNU coreutils.)
Add a test for TODOTXT_DATE_ON_ADD to exercise this functionality.
Signed-off-by: Emil Sit <sit@emilsit.net>
Add a test_todo_session function to test-lib.sh that enables
easy recording of input and output from todo.sh (including
annotation of exit status for testing error cases).
Begin to port and re-factor testsuite.txt into smaller
test cases, starting with basic add list functionality
and replace functionality.
Thanks to Philippe Teuwen <phil@teuwen.org> for feedback
and improvements.
Signed-off-by: Emil Sit <sit@emilsit.net>
Instead of directly setting a value in todo.cfg, let the user
know what the default is and how to customize it. This allows
developers the flexibility of changing the default in todo.sh
without having to worry about fixing people's config files.
Signed-off-by: Emil Sit <sit@emilsit.net>
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>
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>
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>
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>
Add a basic test framework, borrowed from the framework used
by git.git. A shell script library (tests/test-lib.sh) helps
generate the fixtures, and simplifies the process of writing
test scripts. Tests can be run as a suite (via 'make test')
or individually (sh tests/t0000-config.sh). Results are aggregated
upon completion. Includes a detailed README.
A basic test of config file processing is part of this commit.
Signed-off-by: Emil Sit <sit@emilsit.net>
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>
Borrowing slightly from git.git, derive a VERSION-FILE
from the current state of user's git working directory.
The VERSION is derived relative to the latest git annotated
tag object (using git-describe) and includable either in
shell scripts or in Makefiles.
The basic 'make dist' target generates a .tar.gz and a .zip
file named by the detected version.
Also include a basic clean target and dummy test target.
Signed-off-by: Emil Sit <sit@emilsit.net>
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>
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>
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>