xaizek / dit (License: GPLv3) (since 2018-12-07)
Command-line task keeper that remembers all old values and is meant to combine several orthogonal features to be rather flexible in managing items.
Commit 5d11f09e3b3e70f83daee734f38a23bb8dd806e1

Add _any pseudo key for conditions
As its name suggests it matches any field.
Author: xaizek
Author date (UTC): 2018-10-31 22:13
Committer name: xaizek
Committer date (UTC): 2018-10-31 22:19
Parent(s): 2c70f5c0814e91e352eb282492a619995adc63e6
Signing key: 99DC5E4DB05F6BE2
Tree: 55c2cf0257a2fc83aca4f80272f5dbf6ffcabff3
File Lines added Lines deleted
docs/04-commands.md 3 0
src/ItemFilter.cpp 10 2
tests/ItemFilter.cpp 9 0
File docs/04-commands.md changed (mode: 100644) (index f2d2d0a..3f1d532)
... ... key op value
105 105
106 106 Extra spaces are allowed, but don't forget to escape them (with \\ or quotes). Extra spaces are allowed, but don't forget to escape them (with \\ or quotes).
107 107
108 Key in a condition can be a pseudo value "\_any" which matches with any existing
109 field of an item.
110
108 111 Command composition Command composition
109 112 ------------------- -------------------
110 113
File src/ItemFilter.cpp changed (mode: 100644) (index 56abf20..6692066)
... ... ItemFilter::~ItemFilter()
53 53 bool bool
54 54 ItemFilter::passes(Item &item) const ItemFilter::passes(Item &item) const
55 55 { {
56 return passes([&item](const std::string &f) {
57 return std::vector<std::string>{ item.getValue(f) };
56 return passes([&item](const std::string &key) {
57 std::vector<std::string> values;
58 if (key == "_any") {
59 for (const std::string &key : item.listRecordNames()) {
60 values.push_back(item.getValue(key));
61 }
62 } else {
63 values.push_back(item.getValue(key));
64 }
65 return values;
58 66 }); });
59 67 } }
60 68
File tests/ItemFilter.cpp changed (mode: 100644) (index 1c3b2f1..98d483f)
... ... TEST_CASE("Error messages add up", "[item-filter]")
47 47
48 48 REQUIRE(split(error, '\n').size() == 4); REQUIRE(split(error, '\n').size() == 4);
49 49 } }
50
51 TEST_CASE("_any pseudo field", "[item-filter]")
52 {
53 Item item = Tests::makeItem("id");
54 item.setValue("title", "title");
55
56 ItemFilter filter({ "_any==title" });
57 REQUIRE(filter.passes(item));
58 }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/dit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/dit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master