#21 Move method to gather tags to CLI

This commit is contained in:
Thomas Lauf 2018-05-12 18:47:19 +02:00 committed by lauft
parent d8169d7952
commit db13bd403f
3 changed files with 18 additions and 6 deletions

View file

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -66,6 +66,7 @@ public:
std::string getBinary () const; std::string getBinary () const;
std::string getCommand () const; std::string getCommand () const;
std::set <int> getIds () const; std::set <int> getIds () const;
std::vector<std::string> getTags () const;
std::string dump (const std::string& title = "CLI Parser") const; std::string dump (const std::string& title = "CLI Parser") const;
private: private:

View file

@ -41,15 +41,12 @@ int CmdTag (
std::set <int> ids = cli.getIds (); std::set <int> ids = cli.getIds ();
if (ids.empty ()) 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")) throw std::string ("IDs must be specified. See 'timew help tag'.");
tags.push_back (arg.attribute ("raw"));
} }
std::vector<std::string> tags = cli.getTags ();
// Load the data. // Load the data.
// Note: There is no filter. // Note: There is no filter.
Interval filter; Interval filter;