mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
#21 Add implicit @1 to command 'untag'
- Extend interval assertions - Add interval assertions to tests for command 'tag' - Add interval assertions to tests for command 'untag'
This commit is contained in:
parent
c595132a9c
commit
10dfa64cfa
5 changed files with 184 additions and 64 deletions
|
@ -103,7 +103,6 @@ int CmdTag (
|
|||
//TODO validate (cli, rules, database, i);
|
||||
database.modifyInterval (tracked[tracked.size () - id], i);
|
||||
|
||||
// Feedback.
|
||||
if (rules.getBoolean ("verbose"))
|
||||
{
|
||||
std::cout << "Added " << joinQuotedIfNeeded (" ", tags) << " to @" << id << '\n';
|
||||
|
|
|
@ -39,15 +39,11 @@ int CmdUntag (
|
|||
{
|
||||
// Gather IDs and TAGs.
|
||||
std::set <int> ids = cli.getIds ();
|
||||
std::vector<std::string> tags = cli.getTags ();
|
||||
|
||||
if (ids.empty ())
|
||||
throw std::string ("IDs must be specified. See 'timew help untag'.");
|
||||
|
||||
std::vector <std::string> tags;
|
||||
for (auto& arg : cli._args)
|
||||
if (tags.empty ())
|
||||
{
|
||||
if (arg.hasTag ("TAG"))
|
||||
tags.push_back (arg.attribute ("raw"));
|
||||
throw std::string ("At least one tag must be specified. See 'timew help untag'.");
|
||||
}
|
||||
|
||||
// Load the data.
|
||||
|
@ -78,7 +74,22 @@ int CmdUntag (
|
|||
}
|
||||
}
|
||||
|
||||
// Apply tags to ids.
|
||||
if (ids.empty ())
|
||||
{
|
||||
if (tracked.empty ())
|
||||
{
|
||||
throw std::string ("There is no active time tracking.");
|
||||
}
|
||||
|
||||
if (!tracked.back ().range.is_open ())
|
||||
{
|
||||
throw std::string ("At least one ID must be specified. See 'timew help tag'.");
|
||||
}
|
||||
|
||||
ids.insert (1);
|
||||
}
|
||||
|
||||
// Remove tags from ids.
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue