mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
#21 Move method to gather tags to CLI
This commit is contained in:
parent
d8169d7952
commit
db13bd403f
3 changed files with 18 additions and 6 deletions
14
src/CLI.cpp
14
src/CLI.cpp
|
@ -539,3 +539,17 @@ std::set<int> CLI::getIds() const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector<std::string> CLI::getTags () const
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
|
||||
for (auto& arg : _args)
|
||||
{
|
||||
if (arg.hasTag ("TAG"))
|
||||
tags.push_back (arg.attribute ("raw"));
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
std::string getBinary () const;
|
||||
std::string getCommand () const;
|
||||
std::set <int> getIds () const;
|
||||
std::vector<std::string> getTags () const;
|
||||
std::string dump (const std::string& title = "CLI Parser") const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -41,15 +41,12 @@ int CmdTag (
|
|||
std::set <int> ids = cli.getIds ();
|
||||
|
||||
if (ids.empty ())
|
||||
throw std::string ("IDs must be specified. See 'timew help tag'.");
|
||||
|
||||
std::vector <std::string> tags;
|
||||
for (auto& arg : cli._args)
|
||||
{
|
||||
if (arg.hasTag ("TAG"))
|
||||
tags.push_back (arg.attribute ("raw"));
|
||||
throw std::string ("IDs must be specified. See 'timew help tag'.");
|
||||
}
|
||||
|
||||
std::vector<std::string> tags = cli.getTags ();
|
||||
|
||||
// Load the data.
|
||||
// Note: There is no filter.
|
||||
Interval filter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue