mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Extract function getDomReferences
and move it to CLI
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
29cc9e8a0a
commit
422e49bacb
3 changed files with 25 additions and 11 deletions
16
src/CLI.cpp
16
src/CLI.cpp
|
@ -606,3 +606,19 @@ Duration CLI::getDuration () const
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::vector <std::string> CLI::getDomReferences () const
|
||||||
|
{
|
||||||
|
std::vector<std::string> references;
|
||||||
|
|
||||||
|
for (auto &arg : _args)
|
||||||
|
{
|
||||||
|
if (arg.hasTag ("TAG") &&
|
||||||
|
arg.hasTag ("FILTER"))
|
||||||
|
{
|
||||||
|
references.emplace_back (arg.attribute ("raw"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return references;
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ public:
|
||||||
std::vector<std::string> getTags () const;
|
std::vector<std::string> getTags () const;
|
||||||
std::string getAnnotation() const;
|
std::string getAnnotation() const;
|
||||||
Duration getDuration() const;
|
Duration getDuration() const;
|
||||||
|
std::vector<std::string> getDomReferences () const;
|
||||||
std::string dump (const std::string& title = "CLI Parser") const;
|
std::string dump (const std::string& title = "CLI Parser") const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -38,18 +38,15 @@ int CmdGet (
|
||||||
Database& database)
|
Database& database)
|
||||||
{
|
{
|
||||||
std::vector <std::string> results;
|
std::vector <std::string> results;
|
||||||
for (auto& arg : cli._args)
|
std::vector <std::string> references = cli.getDomReferences ();
|
||||||
{
|
|
||||||
if (arg.hasTag ("TAG") &&
|
|
||||||
arg.hasTag ("FILTER"))
|
|
||||||
{
|
|
||||||
std::string reference = arg.attribute ("raw");
|
|
||||||
std::string value;
|
|
||||||
if (! domGet (database, rules, reference, value))
|
|
||||||
throw format ("DOM reference '{1}' is not valid.", reference);
|
|
||||||
|
|
||||||
results.push_back (value);
|
for (auto& reference : references)
|
||||||
}
|
{
|
||||||
|
std::string value;
|
||||||
|
if (! domGet (database, rules, reference, value))
|
||||||
|
throw format ("DOM reference '{1}' is not valid.", reference);
|
||||||
|
|
||||||
|
results.push_back (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << join (" ", results) << '\n';
|
std::cout << join (" ", results) << '\n';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue