The use of the default read command will not allow the user to use arrow keys and shortcuts to enter the data when doing a replace or entering any input, which can be frustrating. Besides, backslashed are interpreted and can be mangled.
- Using the `-e` option will trigger the use of the readline library: you can then, as expected in bash, use the arrow keys and all shortcuts to move around the line before pressing enter.
- Using the `-r` option will prevent the interpretation of the "" and insert them as typed, useful when pasting code:
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.
POSIX sed doesn't support regex branches; I don't want to switch to modern regexp (via -E), since that makes more characters special. Rather, expand the alternatives into two sed commands.
Usually (i.e. when a pager is available), the help() output is piped through the pager, and then the return code will be the one of the pager. So the exit 1 at the end of help() doesn't make much sense, and should be abolished for consistency.
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.
For ls / _list(), custom add-ons can use post_filter_command for additional filtering before the highlighting is applied. Let's allow that for listall and listpri, too, although they employ post_filter_command themselves.
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.
Extract a new function _format() (and getPadding(), both also exported for add-ons) from _list(), which includes the main formatting and filtering pipeline, without the file handling and verbose summary. This can receive the todo file via stdin, so the listall action is able to format the concatenated files without going through a temporary file.
Eventually, after further refactorings, _format() could be used for actual formatted verbose messages in all commands; currently, the raw, unformatted task is printed.
After the recent refactorings, the temporary file is only needed for the listall action. Therefore, the creation-checks and eventual cleanup can be restricted to the listall action, which should slightly speed up the overall script execution.
So far, the listpri action only supports a single priority. Allowing priority ranges (e.g. todo.sh listpri A-C @work) is a simple but useful enhancement.
Note: The syntax extension only clashes with the [TERM] filtering in a few corner cases, and this can be worked around (e.g. "todo.sh listpri A-Z A-Z" lists all prioritized tasks containing the text A-Z).
No need to spawn off another process for this; we can do this inside the sed command that joins the task numbers with the task text.
Note: The sed on OS X does not understand the \+ bound, only in the form of + when used with -E. Instead, I chose to fall back to the \{1,\} basic regexp, in the hope that it is very portable, and to avoid introducing extended regexps to the script.
The sed command of BSD / OS X doesn't like { command } blocks in a single expression. So move the (dynamic) deduplicate sed command(s) to the end, and use a label to access them. This also makes the entire sed script somewhat easier to understand.
When the last reported values are identical to the current values, do not append the same information (just with a new timestamp) to the report. Instead, just print the last report line.
With this, the report action can be scheduled periodically (e.g. via cron) without artificially inflating the report file.
This was meant to write a report header on the initial report run, but as it mistakenly used TODO_FILE instead of REPORT_FILE, it was inactive, and also missing in the tests. Let's just remove it; the format is simple, anyway.
The report action should delegate to archive; it previously (half) did this via duplicated code (and forgot to defragment empty lines, so the tally could be off, and kept silent about the archiving).
The do action directly invoked archive(); if the user had extended / modified the archive action via an eponymous custom action, it would not run. Therefore, always invoke archive through another call of todo.sh, so that a possible custom action is considered.