Commit graph

275 commits

Author SHA1 Message Date
Tomas Babej
0bc92d6115
meta: Adjust copyright headers 2021-09-05 12:02:07 -04:00
Tomas Babej
8b30046d0a CLI2: Simplify code by using const quote string
The "\'" string is equal to "'", which is already stored in the quote
variable, so we might as well use that.

Thanks to Sebastian Uharek for the review suggestion.
2021-08-28 21:01:29 -04:00
Tomas Babej
ddf2f122a2 CLI2: Pre-reserve the size of the escaped string 2021-08-28 21:01:29 -04:00
Tomas Babej
c119b6d1de CLI2: Support escaped utf-8 characters 2021-08-28 21:01:29 -04:00
sebu06
0523ada9fc Fixed bug with double escaped single quotes
Before, the parser always escaped single quotes, independent of the quotes being escaped already. This is now fixed.
2021-08-28 21:01:29 -04:00
Tomas Babej
8cad6487c7 CLI2: Call uses_context from child classes, if applicable 2021-08-21 08:25:06 -04:00
Tomas Babej
89a6f2b629 CLI2: Apply UUID/ID context break only for readable context
The purpose of this break is to not apply the context on commands like

    task 4 info

so that we can still refer to tasks directly (using their ID/UUID
references) even if they fall outside of the currectly active context.

However, this break should not be applied for writeable context. This is
because the lexer can (a bit misleadingly) label parts of the desription
of the new task as number/identifier tokens

   task add Replace 3 parts of the puzzle abc123
                    ^                     ^
                    type::number          type:uuid

which would trigger the break unnecessarily.

Closes #2550.
2021-08-15 22:50:55 -04:00
Rosen Penev
5c137f5c8f use emplace
Allows removing the constructor name as emplace forwards the arguments
directly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-05 02:03:59 -04:00
Scott Mcdermott
ac3572a4f5 CLI2: New filter attribute modifier "by", uses '<=' for comparison
This patch allows e.g. due.by:tomorrow that includes all of tomorrow,
because it uses less than or equal to, rather than just less than, like
'before' modifier does.  This allows matching the last second of the day
when filtering by "due.by:eod", and more generally allows date filters
with an inclusive end-interval specification.

Closes #2536
2021-07-18 09:45:00 -04:00
Tomas Babej
c3f9d09d22 performance: Cache used command value
The detected command does not change once CLI2::analysis has been
performed. Cache the value of the command to avoid the need to
re-discover the correct value each time we're interested in it.
2021-04-24 10:47:28 -04:00
Tomas Babej
a19773873a performance: Cache CLI2::canonicalize lookups
Canonicalization of attributes or attribute prefixes happens once per
every single task considered in the filtering process. It maps short,
prefixed names to their full-length versions, for example:

"pro" -> "project" in the expression "project:Home"

It follows that such process is not task-dependant and as such the
lookups can be cached.
2021-04-24 10:47:28 -04:00
Rosen Penev
3cafb5257e clang-tidy: use = default
Found with modernize-use-equals-default

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-23 00:15:06 -04:00
Rosen Penev
8ffb85b327 clang-tidy: use '' for single character find
Found with performance-faster-string-find

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-22 23:18:16 -04:00
Tomas Babej
bd0d907335 CLI2: Apply desugaring of plain filter args to date args
This ensures that commands like `task marc` perform description
substring search on `marc`.

Closes #2451.
2021-04-14 02:44:33 -04:00
Tomas Babej
475a16b3d4 CLI2: Fix docstring for desugarFilterPlainArgs
Desugaring is applied also for tokens of Lexer::type::identifier, make
sure the docstring correctly documents that.
2021-04-14 02:44:33 -04:00
Tomas Babej
1bba59e972 CLI2: Move the recursion block to the right place in addContext 2021-04-03 15:01:39 -04:00
Tomas Babej
351c3b025c getTaskContext: Allow getting context info for a non-active context 2021-04-03 15:01:39 -04:00
Tomas Babej
9a380887ee CLI2: Simplify context determination
Simlifies by offloading portion of the logic into the singleton Context
class (which has nothing to do with the task context per se, just a
implementation singleton).
2021-04-03 15:01:39 -04:00
Tomas Babej
5716f5abb7 CLI2: Generalize method to add context to support writeable context 2021-04-03 15:01:39 -04:00
Tomas Babej
5c3cf0f438 CLI2: Implement inserting modification arguments
Method to inject mods into the command, to be used by writeable context.
2021-04-03 15:01:39 -04:00
Tomas Babej
9128798fee CLI2: Generalize 'add' to insert arguments at arbitrary position 2021-04-03 15:01:39 -04:00
Tomas Babej
a2c3d224d3 CLI2: Generalize _context_filter_added latch name 2021-04-03 15:01:39 -04:00
Tomas Babej
456dfdc8cf CLI2: Handle empty parentheses expressions
Since taskwarrior is a CLI tool, it is likely that it is interacted with
programmatically. As such, expressions that a human would not type, but
are syntactically correct are bound to occur. In particular, task
currently is not able to handle empty parentheses expressions:

    task +PENDING '(' ')'

This is due to "and" operator being injected between +PENDING (which
translates to '( status = pending )' and '('.

Modify the insertJunctions to not insert the 'and' operator between two
sub-expressions if one of them is an empty parentheses expression.

Closes #1896.
2021-01-30 21:40:41 -05:00
Tomas Babej
a1471b67fb CLI2: Do not attempt to evaluate values of string attributes 2021-01-30 21:40:41 -05:00
Tomas Babej
9017cd6e53
doc: Update copyright to 2021 2021-01-02 02:48:22 -05:00
Julien Rabinow
1aa77c9ede fix home_dir variable definition 2020-12-09 20:15:22 -05:00
Paul Beckingham
3e0a428185 Revert "[clang-tidy] Use .empty instead of comparing size"
This reverts commit a331cceded.
2020-12-05 16:18:37 -05:00
Paul Beckingham
e3e158bf6a Revert "[clang-tidy] Replace push_back with emplace_back"
This reverts commit 897759e4dc.
2020-12-05 16:18:37 -05:00
Paul Beckingham
ead50d4d6e Revert "[clang-tidy] Use default to initialize constructors"
This reverts commit bf40ea8816.
2020-12-05 16:18:37 -05:00
Paul Beckingham
aa841f98c9 Revert "[clang-tidy] Add const where it makes sense"
This reverts commit defd49b13d.
2020-12-05 16:18:37 -05:00
Paul Beckingham
8cf4e3de08 Revert "[clang-tidy] Access static member through qualified-id"
This reverts commit 6cd15235be.
2020-12-05 16:18:37 -05:00
Paul Beckingham
5502729131 Revert "[clang-tidy] Switch C headers to C++ ones"
This reverts commit 0344856d65.
2020-12-05 16:18:37 -05:00
Paul Beckingham
3eb209f248 Revert "[clang-tidy] Use '' for single characters"
This reverts commit e3ceda9ce1.
2020-12-05 16:18:37 -05:00
Paul Beckingham
702af00435 Revert "[clang-tidy] Remove redundant const"
This reverts commit 55d103c491.
2020-12-05 16:18:37 -05:00
Paul Beckingham
364b4ea8bd Revert "[clang-tidy] Simplify boolean expressions"
This reverts commit 51870dff34.
2020-12-05 16:18:37 -05:00
Paul Beckingham
6ad1b7d0da Revert "[clang-tidy] match loop size with size()"
This reverts commit 68c446ea08.
2020-12-05 16:18:37 -05:00
Rosen Penev
68c446ea08 [clang-tidy] match loop size with size()
Found with bugprone-too-small-loop-variable

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
51870dff34 [clang-tidy] Simplify boolean expressions
Found with readability-simplify-boolean-expr

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
55d103c491 [clang-tidy] Remove redundant const
Found with readability-const-return-type

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
e3ceda9ce1 [clang-tidy] Use '' for single characters
Found with performance-faster-string-find

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
0344856d65 [clang-tidy] Switch C headers to C++ ones
Found using modernize-return-braced-init-list

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
6cd15235be [clang-tidy] Access static member through qualified-id
Found readability-static-accessed-through-instance

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
defd49b13d [clang-tidy] Add const where it makes sense
Found with readability-redundant-string-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
bf40ea8816 [clang-tidy] Use default to initialize constructors
Found with modernize-use-equals-default

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
897759e4dc [clang-tidy] Replace push_back with emplace_back
Found with modernize-use-emplace

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Rosen Penev
a331cceded [clang-tidy] Use .empty instead of comparing size
Found with readability-container-size-empty

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-12-05 15:03:43 -05:00
Tomas Babej
a09f9d48ab Update copyright to 2020 2020-11-21 12:27:05 -05:00
taiyu
d2b1662a39 Simplify CLI2::get* methods. allow rc=... 2019-02-07 08:41:25 -05:00
taiyu
8514071f19 applyOverrides: add messages after overrides 2019-02-07 08:41:25 -05:00
Tomas Babej
8066e4e6e2 meta: Update copyright year 2019-01-01 08:46:21 -05:00