* TESTSFIX: t0000-config.sh may unintentionally pick up existing user config in `$XDG_CONFIG_HOME/todo/config`
This corner case was missed when the XDG alternative config location was introduced, likely because the variable isn't set by default on Ubuntu or Mac OS, and none of the developers had a config there.
HOME is already redirected to the current working directory; as `XDG_CONFIG_HOME` is just a config alternative that has a fallback to `$HOME/.config`, simply unset it.
Fixes#347
* TESTSFIX: User add-ons that override built-in actions may break tests
If `TODO_ACTIONS_DIR` is already defined, the defaulting in todo.sh are skipped. The user may have custom add-ons that override built-in actions; any incompatible behavior would negatively affect the tests then.
By setting the variable to the first default location, we avoid this interference.
* ENH: Allow to customize what can be before / inside / after +project and @context
I noticed that todo.sh mistakenly picks up some random stuff as projects and contexts. The todo.txt specification is very lenient in what makes those (allowing any length of non-whitespace characters), but in practice, every user has its own idea of the set of used words. This change allows (expert) users to tweak the pattern (via TODOTXT_SIGIL_VALID_PATTERN), to be able to reduce the amount of "false positives" that listproj and listcon show.
Additionally, there's a (mainly unspecified) extension mechanism in the form of key:value, which often is used to implement custom "markers", like w:something to make a task blocked and waiting for "something". It would be nice to be able to refer to @contexts (and maybe also +projects), but the default syntax (which requires whitespace around those) doesn't allow it, and these context then don't show up in searches, which is unfortunate. The added TODOTXT_SIGIL_BEFORE_PATTERN and TODOTXT_SIGIL_AFTER_PATTERN allow to tweak the syntax to accommodate this.
The implementation just exchanges grep with a corresponding sed pipeline step, which shouldn't negatively affect the performance at all (as sed is one of the main commands used thoughout the script), but which allows for the additional matching flexibility.
* FIX: Compatibility: sed \? multi not supported on MacOS
Use the POSIX \{0,1\} instead.
* FIX: Compatibility: sed \| multi not supported on MacOS
Concatenate both alternatives as optional matches; this is only an approximation but satisfies the test case here. It would probably be better if the entire sed code used extended regular expression syntax (-E) instead of basic ones (-e), but that change would also affect all add-ons. As this is an optional customization feature, uses who really need this either also have to work around, or supply a GNU sed port on MacOS.
* FIX: Compatibility: sed \+ multi not supported on MacOS
Use the POSIX \{1,\} instead.
Co-authored-by: Ali Karbassi <ali@karbassi.com>
* Refactoring: Use regular expression match instead of case globbing for actions taking a SRC argument
Making it consistent with the test for MOVE_COMMAND_PATTERN, and allowing to extend the pattern with custom actions in the future.
* Refactoring: Move the anchoring and grouping out of MOVE_COMMAND_PATTERN
So that additional (custom) add-on actions can be configured in the future.
* ENH: Enable file completion for add-on actions via _todo_file{1,2,3}_actions
Allowing completion of todo files directly after the add-on action (1), with one (2) / two (3) arguments in between. This should handle most cases.
In order to configure the add-on completion, the corresponding configuration variable has to be defined in the user's shell (e.g. via ~/.bashrc):
_todo_file1_actions='myaction|anotheraction'
* add highlighting of dates, item numbers, and metadata
* add test for highlighting of dates, item numbers, and metadata
Co-authored-by: Ali Karbassi <ali@karbassi.com>
* Handle missing EOL in todo.txt
This can happen easily with certain editors (such as Mousepad) that do not automatically add a newline character at the end of a file.
In _addto(), ensure a trailing newline via sed (taken from https://unix.stackexchange.com/a/31955/18876).
Fixes#294
* Tests: Add basic coverage of move
* Handle missing EOL in todo.txt for move, too
This can happen easily with certain editors (such as Mousepad) that do not automatically add a newline character at the end of a file.
* Refactoring: Extract fixMissingEndOfLine()
* FIX: Compatibility: sed \+ multi not supported on MacOS
Use the POSIX \{1,\} instead.
Co-authored-by: Ali Karbassi <ali@karbassi.com>
- In macOS 10.15, the `date` command adds a "-R" flag. This can be seen in the default error display. Since the flags have changed, the grep command to find which version of macOS date binary we have. Because of this change, we need to do our own check for macOS 10.15.
- Remove windows from the github actions as this tool is not for Windows, currently.
Adds the config / env variable `TODOTXT_PRIORITY_ON_ADD`, which when set to one of the capital letters `A` to `Z` is given as a priority to a new task, if a priority is not given on command line.
Addons can be placed in subfolders with the same name as the action,
in order to be able to e.g. clone git repos into the TODO_ACTIONS_DIR
rather than having to download addons and manage updates manually.
Closes#120
Because @contexts and +projects are metadata as much as they are text,
it can be nice to highlight them independently of the coloring of the line
that contains them. This is tough to do correctly in
a TODOTXT_FINAL_FILTER because doing it at that layer requires
re-parsing the text of the line to find the appropriate PRI_$x color to
reset to after coloring the word, or trying to reverse engineer where
the color codes inserted by todo.sh end and the user's text begins (and
vice versa).
Closes#119
Request from exatto (http://article.gmane.org/gmane.comp.diary.todotxt/4699), who doesn't want to use done.txt and report.txt.
Also consider character devices (-c; /dev/null is one) in the file existence checks so that no empty file is then created.
If not found elsewhere, look for the config file in /etc/todo/config.
`make install` installs a global config file, setting TODO_DIR=~/.todo.
todo.sh creates TODO_DIR if it doesn't exist.
The user may need the help to solve any fatal error that appears while todo.sh isn't properly set up. As the help actions do not depend on any setting that the fatal errors check, we can still invoke them.
Factor out dieWithHelp() and use that for printing the fatal errors.
Need to make match of preceding priority optional.
Also tighten patterns for priority and done marker by anchoring them to the front, as the leading task number has already been substituted away.
When the command-under-test fails with a non-zero exit code, neither the different exit code nor any output differences are printed. Also, there's a lot of duplication between test_expect_output and test_expect_code_and_output. So, let's fix both by delegating the first to the latter.
Currently, the only way to get usage help for a custom action is to use "todo.sh help" and scroll / search for the action name. (Or try to call the action without / with invalid parameters to hopefully get a one-line syntax summary.)
This extends the help command to print the usage of optionally passed custom action names.
This applies e24777fa2c to todo.cfg, too, and adds a verification to the existing test.
Note: Because todo.cfg is preprocessed by test-lib, we use the original config from the working copy, not the copy inside the test fixture.
An empty line is used to delimit test commands in test_todo_session. (This wasn't properly reflected in the usage comment, fixed that, too.) This prevents us from testing commands that include empty lines. (Currently, there is no such output in todo.sh, but custom add-ons may have this.)
Instead of forcing the test to filter out the empty lines, extend the syntax to allow empty lines in the expected output by escaping them with a single backslash. (When redirecting via <<EOF, the backslash itself must be escaped = doubled; better use <<'EOF'.)
Currently, todo.sh produces no indented output, so this hasn't affected tests so far. I found this while testing one of my custom actions with the test-lib.
By unsetting IFS, the read command won't strip off leading and trailing whitespace while parsing the test session definition.
The todo_completion had the problem that it didn't consider the todo.cfg itself for the location of TODO_ACTIONS_DIR, it just tried the default location or a globally exported config value. With the injection of custom configuration now in place, we can actually delegate the listing to todo.sh itself.
The added built-in "listaddons" command is used for that; it may also be helpful for troubleshooting or to find out about available add-ons. (But the help / shorthelp commands offer more information.)
Additionally, completion is now more precise; only executable actions and no subdirs are listed now; this is also covered by the enhanced test.
The last bonus: The custom add-on actions are now only determined when there's actually completion of commands.
This was previously not supported; todo_completion always used plain todo.sh from the PATH. Now it's possible to override the used executable (and configuration used through _todo_sh, set from a completion function wrapper.
Cp. http://tech.groups.yahoo.com/group/todotxt/message/4003
This extension of test_todo_completion additionally takes the completion function to use, so that customized completions for todo.sh aliases can be tested.
The completion may unexpectedly abort somewhere.
Additionally, reformat the failure messages (don't prepend a "*", this should be reserved to mark the individual test runs) and use "compreply" instead of "output", so that it's already clear from the diff output that the completion is being tested.