518 Commits

Author SHA1 Message Date
9e65d3602e Merge remote-tracking branch 'upstream/master' 2024-12-23 13:06:08 +01:00
Ingo Karkat
9623f77af8 ENH: Reuse the todo.sh alias for completion
Having to define a completion function wrapper is cumbersome. I had seen the trick of simply using ${COMP_WORDS[0]} (i.e. the used todo.sh command itself) from Paul Mansfield (https://github.com/the1ts/todo.txt-plugins/blob/develop/bash_completion/todo.txt#L7), which neatly avoids this.
By keeping the _todo_sh variable, this is a one-line change and it still allows the old way of using the override in a wrapper function. (So users aren't forced to change their customizations when upgrading.)
Tests are adapted to verify that the alias is used, and still verify the wrapper function as well.
The documentation is simplified because there's normally no need for the completion wrapper function.
2024-10-31 06:28:34 +01:00
Ingo Karkat
a916aa97df Update build platforms and outdated checkout action
Merge pull request #438 from inkarkat/bump/workflow
2024-09-26 14:51:42 +02:00
Ingo Karkat
b00c212fcc FIX: Regression: Compatibility: Bash on MacOS 12 does not support ${var^^} (after ca444e4)
This went undetected because the CI/CD pipeline was broken again due to an outdated MacOS image.
Continue to use tr for uppercasing. Enable pipefail so that grep (which needs to happen before the uppercasing) result is still considered.

(This corrects commit ca444e4000)
2024-09-21 12:39:22 +02:00
Ingo Karkat
c2b3d01024 Build: ENH: Add dependabot configuration to offer updates to outdated GitHub actions
This will automatically scan our workflow once a week and open PR(s) with updates to GitHub actions.
2024-09-21 12:39:22 +02:00
Ingo Karkat
26a82c3c2f Build: ENH: Enable manual workflow run
Helpful for testing.
2024-09-21 12:39:22 +02:00
Ingo Karkat
75dc8cdaed Bump: checkout action to v4
To silence this warning:
> The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2
2024-09-21 12:39:22 +02:00
Ingo Karkat
a6d69811d4 Bump: Build platforms to latest available: Ubuntu 24.04, MacOS 14
MacOS 11 is unsupported and the builds are just hanging due to the missing image.
2024-09-21 12:38:47 +02:00
Ingo Karkat
401653fc75 Finally integrate various features and fixes from inkarkat
Merge pull request #405 from inkarkat/master
2024-09-21 10:03:21 +02:00
Ingo Karkat
ca444e4000 ENH: Allow concatenation of multiple priorities [-ranges] for listpri
It can be useful to filter for non-consecutive priority ranges. By enforcing uppercase in that added syntax, overlap with general TERM(s) (e.g. "foo-bar") can be mostly avoided (and in the rare case of having to filter by all-uppercase TERM(s) one can always pass the default A-Z filter, anyway).
2024-09-16 08:24:07 +02:00
Florian Tham
3a369110d6 Prio-Tasks färben nicht mehr die ganze Zeile ein 2024-03-08 14:57:53 +01:00
Florian Tham
afdc68fc67 again: wie allg. Metadaten behandeln 2024-03-06 07:56:05 +01:00
Florian Tham
e6d80bac04 merge upstream/master 2024-02-29 15:07:09 +01:00
Edwin Kofler
fd753c6c2e style: Fix typo in pull request template (#420) 2023-08-16 14:09:15 -05:00
Ingo Karkat
ea17510e4e Merge remote-tracking branch 'upstream/master' 2023-06-30 17:13:04 +02:00
Ingo Karkat
c8fa5f1ebc Fix failing MacOS 11 tests and remove obsolete build platforms
Integrated via #415

Merge branch 'chrysle:fix-macos-11-tests'
2023-06-30 17:10:37 +02:00
Ingo Karkat
aa38153586 Housekeeping: Remove obsolete build platforms
GitHub runners for Ubuntu 18.04 and MacOS 10.15 are not available any longer.
2023-06-30 16:59:44 +02:00
chrysle
b10904bb20 Remove hacks 2023-06-30 15:11:44 +02:00
chrysle
ef5b71496d Fix macOS tests 2023-06-30 15:05:39 +02:00
Ingo Karkat
884b5deb6e Merge branches 'enh/cfg-verbose', 'doc/readme-config' and 'rename-completion' 2023-01-22 16:14:36 +01:00
Ingo Karkat
2937a8b316 Merge branch 'fix/stderr' 2023-01-21 19:51:40 +01:00
Ingo Karkat
ef419f3594 Use die() / print to stderr for error conditions
To indicate that something went wrong (e.g. the task already was unprioritized).
Note: For actions that handle multiple ITEMs in a loop, we cannot use die() as that would abort processing of any following ITEM(s). Instead, use a status variable and set it to 1 on error, then exit at the end.
2023-01-21 19:01:24 +01:00
Ingo Karkat
803881998f FIX: Use standard error for die() and dieWithHelp()
By convention, error output should be printed to standard error, not standard out. Same for the usage help that may accompany the error message.
2023-01-21 18:59:32 +01:00
Ingo Karkat
4cd6822946 Merge branches 'read-p' and 'testfix/cygwin-customaction' 2022-06-18 12:46:28 +02:00
Ingo Karkat
466265175b Refactoring: Use read -p MSG instead of doing echo -n MSG separately
I've seen strange readline editing behavior when the editing doesn't start at the first column: I can actually backspace into the prepended message (with Del, Ctrl-W or Ctrl-U), and then the whole edit becomes messed up.

read can output a prompt on its own (hopefully in all versions of Bash that we aim to support - the tests will tell), and that doesn't have this problem, and it's also a bit cleaner and shorter.

The prompt is only displayed if input is coming from a terminal. For the tests (currently only deletion and move confirmations are covered), this means that the prompt itself cannot be covered, and an empty line instead has to be expected. (On the positive side, this removes the ugly trick with $SPACE.)
2022-06-18 12:26:17 +02:00
Ingo Karkat
bab2af9501 Tests: Refactoring: Extract invalidate_action() into actions-test-lib
We don't "shamelessly steal" code, we refactoring it ;-)
2022-06-18 10:57:28 +02:00
Pegasust
1a5600c79c test listaddons: Make pass on Cygwin
If a custom action cannot be made non-executable, it needs to be removed as well (and the test skipped); otherwise its existence will break following tests that assume it's inactive.
2022-06-18 10:49:22 +02:00
Ingo Karkat
b25c791af7 Merge branch 'fix/replace-pri' 2022-06-17 23:38:33 +02:00
Ingo Karkat
28523851d0 replace: Completely merge given priority / date with existing
So that any combination of priority / date entered in the replacement will replace the corresponding original ones, but if they are left out, the original ones will be kept.
In essence, omitted stuff will be kept, added stuff will override, only deletion of existing stuff is not possible (but this is replace, after all).

Fixes #386
2022-06-17 23:12:35 +02:00
Ingo Karkat
491979b76a Renaming: Add .sh extension to completion script
This doesn't matter if (as currently recommended) the script is placed into a eagerly loaded location (like /etc/bash_completion.d/) - any name will do.
However, there's now lazy loading of completion scripts (in /usr/share/bash-completion/completions/), and that only works when the completion script is named exactly like the command the completion is for. As our command is todo.sh (ignoring aliases, which become more complex with lazy loading), the corresponding completion needs to be todo.sh (with the .sh extension) as well. Renaming does not do any harm for our recommended location, but makes it easier for users (and packagers who prepare a todo.sh package) that want to use lazy loading.

See https://github.com/todotxt/todo.txt-cli/issues/383 for the complete discussion.
2022-05-07 20:03:48 +02:00
Ingo Karkat
bf001cef6b Merge branches 'fix/broken-action-symlink' and 'refactor/shellquote' 2022-04-12 08:17:01 +02:00
Ingo Karkat
aef7d8b9e5 Refactoring: Replace shellquote() with printf %q
I didn't know about printf's capability when I introduced quoting 10 years ago. The %q format will do the quoting, and "-v VAR" can be used to reassign to the variable.

Note: The shellquote() function has been exported for reuse by add-ons. I don't think anyone has ever used that (it was mostly intended for my own, extensive extensions, and I never used it), and is trivial to move away from, anyway.
2022-04-12 07:53:07 +02:00
Ingo Karkat
273c465af0 Documentation: Add Configuration section with overview and recommendation to copy the template 2022-03-28 22:24:49 +02:00
Ingo Karkat
7a4da60374 Documentation: Clarify that CONFIG_DIR is for the configuration template
And only coincidentally picked up as the global configuration (if CONFIG_DIR=/etc).

Fixes #377
2022-03-28 22:23:17 +02:00
Ali Karbassi
ea32af34e6 Updated GitHub Actions Environments (#372)
Rather than `*-latest`, I'm specifying specific environments.
2021-12-02 15:49:42 -06:00
Lawrence Liu
d0075e4d57 Different folder to copy ~/.todo.cfg for macOS on arm/x86 CPU (#369) 2021-11-19 07:48:16 -06:00
Ingo Karkat
bd88c20cab Add TODOTXT_VERBOSE to the configuration
There's no command-line option to reduce verbosity (just -v to increase it), so users who would like to remove the additional messages (cp. https://github.com/todotxt/todo.txt-cli/discussions/364) have to configure this, but the variable is hard to find.
Include the default value in commented-out form and some documentation of the possible values.
2021-10-09 19:57:47 +02:00
Ingo Karkat
e1c1c328a2 Robustness: Check for broken symlinks to custom actions and complain
Instead of potentially falling back to the built-in action that a custom action was intended to override, but (e.g. due to file system reorganizations) now results in a broken link. The extension functionality that is then skipped may result in undesired results, but this may not be immedately obvious to the user (if the extension is not particularly verbose), so some data corruption could occur if this remains undetected.
To avoid duplicating (or somehow extracting) all the built-in actions, simply detect _any_ broken symlink; i.e. offer a superset of the required functionality. So this would also complain about a broken symlink to a non-executable custom (auxiliary) file (rarely used) if that is mistakenly passed as a custom action (unlikely).

Fixes #359
2021-09-16 22:15:00 +02:00
Ingo Karkat
1185ab1d5e Refactoring: Extract hasCustomAction() 2021-09-16 21:38:47 +02:00
Ingo Karkat
7792006853 Tests: Refactoring: Extract make_dummy_action()
The action script creation in both test helper functions is pretty similar; extract a function for that so that the invocation is a single command.
2021-09-16 21:38:02 +02:00
a1346054
2d70a0aadf Minor fixes identified through shellcheck and other tools (#350)
* fix whitespace

* fix spelling

* fix whitespace

* unify headers of tests

* fix some issues in tests, identified by shellcheck

* fix bash completions

bash completion files are not supposed to be executable

* fix some issues identified by shellcheck

Co-authored-by: Ali Karbassi <ali@karbassi.com>
2021-08-09 15:03:49 -05:00
Ingo Karkat
ee94a3fac5 Return from user prompt without requiring Enter (#354)
* Tests: Add coverage for del / move without -f, but with prompting

Supplying the user confirmation via "yes".

* Cosmetics: Align inconsistent spacing for before (y/n) prompt

* Refactoring: Extract confirm() function

The user confirmation query had been duplicated (once) in the code.

* Refactoring: confirm(): Leave early if forced

* Return from user prompt without requiring Enter

By just reading a single character (y for yes, anything else: no).



* Tests: Ensure that only a single "y" concludes the confirmation

By switching from "yes" (that endlessly prints newline-separated "y"s) to "printf y".

* t1800-del: Add coverage for negative confirmation

Negative means "anything but y", so "n", "x", and Enter all apply.

* Cosmetics: Add trailing space after (y/n) prompt

So that the user's typed answer is not recorded directly after it, but with separation: "Foo? (y/n) y" instead of "Foo? (y/n)y".

*Compatibility: "read -N 1" is only available in Bash 4.1+

Mac OS still ships with Bash 3.2 :-( Fall back to the original prompting that requires conclusion via Enter then.
Note: Even though the tests use "printf y", this still gets accepted, as there'll be EOF after that. In real use (when stdin from the terminal stays open), a concluding Enter is mandatory, though.

Closes #152
2021-08-06 15:05:11 -05:00
Keith
587833bb4e Default to user writable directory in config (#148)
When a user installs from a package manager (MacPorts, Homebrew, `yum`, etc.), the `todo.sh` script is installed into a restricted folder.  This means that the result of `$(basename "$0")` is a directory where the user cannot write without elevated permissions.  This generates additional noise when the user first runs `todo.sh -h`.  An alternative is to default to the user's personal directory which is known to exist and will be writable by the user.
2021-08-06 09:14:25 -05:00
Tim
eb7feaefb5 Fix problem with spaces in directory path (#276)
If the current directory had spaces in the directory path, this script would fail.
That has been fixed by appropriate use of quotes.

Co-authored-by: Tim Learmont <learmont@NocturnalAviation.com>
Co-authored-by: Ali Karbassi <ali@karbassi.com>
2021-08-03 18:11:27 -05:00
Wallysson
7501d37b45 use builtin "command -v" instead of which (#308) 2021-08-03 18:10:28 -05:00
Ingo Karkat
6ea2b5ae6d Mention all (also XDG) config file locations in help for -d (#343)
* Refactoring: Replace serial checks for `TODOTXT_CFG_FILE` and `TODO_ACTIONS_DIR` with loops

Two fallbacks (like for the actions dir) may still be fine, but we're now supporting so many config locations that a loop is much shorter, and the various locations are much easier to see.

For consistency, also apply this to the actions dir lookup, although it's less of a problem there.

* Refactoring: Apply the first default for `TODOTXT_CFG_FILE` also in the loop

There's no need to handle this separately; either an exported environment variable already exists, or it got assigned via `-d CONFIG_FILE`, or the `test -e` will fail on an empty (or bad non-existing) value, and we enter the fallback loop.

* Mention the actual config file locations in the help for `-d`

Extract the list of default locations into a `configFileLocations` array and join that into a string that then gets interpolated into the help output for `-d` (that so far only mentioned the first default location).

* Comments: Don't favor a single config location in the requirement

* Documentation: Mention `~/.todo/config` as just one of the defaults

As there are several others, now shown in the help for `-d`.

I don't want to duplicate the entire list here, as there's a high risk of those lists diverging.

Fixes #342
2021-08-03 18:06:10 -05:00
Paul Mansfield
353db49814 Allow multiple priorities on single run (#346)
Uses current priority logic and option tests just running multiple times until item and priority pairs are exhausted or stops on first error.

Tests for multiple priorities, multiple re-prioritization and a couple of errors.
2021-08-03 18:03:20 -05:00
Ingo Karkat
f884f73297 TESTSFIX: t0000-config.sh may unintentionally pick up existing user config in $XDG_CONFIG_HOME/todo/config (#349)
* 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.
2021-08-03 17:57:31 -05:00
Ali Karbassi
e4103a8e23 Add Ubuntu 18 to tests (#351) 2021-08-03 17:53:35 -05:00
Ingo Karkat
77c1f34609 Documentation: Clarify basic regexp syntax of TERM in todo.sh list (#335)
* Documentation: Clarify basic regexp syntax of TERM in todo.sh list

And give hints about escaping.
Issue raised by https://github.com/todotxt/todo.txt-cli/discussions/334

* Documentation: Correct quoting in todo.sh help list

Though the double quoting doesn't do harm when the single backslash is followed by the | character (\| is no valid escape sequence), it's technically more correct to use single quotes, and also is more in line with the quoting advice given directly below it.
2021-03-13 13:32:40 -06:00