Permalink
Browse files

Make warning about new tags adhere to :quiet hint

  • Loading branch information...
lauft committed Aug 10, 2018
1 parent b15695d commit ff7e7b46406058afd14bf46c75769f7051fc5261
@@ -102,13 +102,13 @@ std::vector <std::string> Database::allLines ()
}

////////////////////////////////////////////////////////////////////////////////
void Database::addInterval (const Interval& interval)
void Database::addInterval (const Interval& interval, bool verbose)
{
auto tags = interval.tags ();

for (auto& tag : tags)
{
if (_tagInfoDatabase.incrementTag (tag) == -1)
if (_tagInfoDatabase.incrementTag (tag) == -1 && verbose)
{
std::cout << "Note: '" << quoteIfNeeded (tag) << "' is a new tag." << std::endl;
}
@@ -178,7 +178,7 @@ void Database::deleteInterval (const Interval& interval)
// Datafile, then add it back to the right Datafile. This is because
// modification may involve changing the start date, which could mean the
// Interval belongs in a different file.
void Database::modifyInterval (const Interval& from, const Interval& to)
void Database::modifyInterval (const Interval& from, const Interval& to, bool verbose)
{
if (!from.empty ())
{
@@ -187,7 +187,7 @@ void Database::modifyInterval (const Interval& from, const Interval& to)

if (!to.empty ())
{
addInterval (to);
addInterval (to, verbose);
}
}

@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2016, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -46,9 +46,9 @@ class Database
std::string lastLine ();
std::vector <std::string> allLines ();

void addInterval (const Interval&);
void addInterval (const Interval&, bool verbose);
void deleteInterval (const Interval&);
void modifyInterval (const Interval&, const Interval&);
void modifyInterval (const Interval&, const Interval &, bool verbose);

void startTransaction ();
void endTransaction ();
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -98,7 +98,7 @@ int CmdContinue (
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
{
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << '\n' << intervalSummarize (database, rules, interval);
@@ -110,7 +110,7 @@ int CmdContinue (
to_copy.range.end = end_time;

validate (cli, rules, database, to_copy);
database.addInterval (to_copy);
database.addInterval (to_copy, rules.getBoolean ("verbose"));

database.endTransaction ();

@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -64,7 +64,7 @@ int CmdDelete (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

dirty = false;
}
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -62,7 +62,7 @@ int CmdFill (
autoFill (rules, database, to);
validate (cli, rules, database, to);
std::cout << "# to " << to.dump () << "\n";
database.addInterval (to);
database.addInterval (to, rules.getBoolean ("verbose"));

// Note: Feedback generated inside autoFill().
}
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -77,7 +77,7 @@ int CmdJoin (
database.deleteInterval (second);

validate (cli, rules, database, combined);
database.addInterval (combined);
database.addInterval (combined, rules.getBoolean ("verbose"));

database.endTransaction ();

@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -77,7 +77,7 @@ int CmdLengthen (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

dirty = false;
}
@@ -98,7 +98,7 @@ int CmdLengthen (
Duration dur (delta);
i.range.end += dur.toTime_t ();
validate (cli, rules, database, i);
database.addInterval (i);
database.addInterval (i, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << "Lengthened @" << id << " by " << dur.formatHours () << '\n';
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -80,7 +80,7 @@ int CmdMove (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));
}

// Move start time.
@@ -107,7 +107,7 @@ int CmdMove (
database.deleteInterval (tracked[tracked.size () - id]);

validate (cli, rules, database, i);
database.addInterval (i);
database.addInterval (i, rules.getBoolean ("verbose"));

database.endTransaction ();

@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -73,7 +73,7 @@ int CmdResize (

i.range.end = i.range.start + dur.toTime_t ();
validate (cli, rules, database, i);
database.addInterval (i);
database.addInterval (i, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << "Resized @" << id << " to " << dur.formatHours () << '\n';
@@ -75,7 +75,7 @@ int CmdShorten (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

dirty = false;
}
@@ -99,7 +99,7 @@ int CmdShorten (

i.range.end -= dur.toTime_t ();
validate (cli, rules, database, i);
database.addInterval (i);
database.addInterval (i, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << "Shortened @" << id << " by " << dur.formatHours () << '\n';
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -77,10 +77,10 @@ int CmdSplit (
database.deleteInterval (tracked[tracked.size () - id]);

validate (cli, rules, database, first);
database.addInterval (first);
database.addInterval (first, rules.getBoolean ("verbose"));

validate (cli, rules, database, second);
database.addInterval (second);
database.addInterval (second, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << "Split @" << id << '\n';
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -66,7 +66,7 @@ int CmdStart (

for (auto& interval : flatten (modified, getAllExclusions (rules, modified.range)))
{
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (database, rules, interval);
@@ -85,7 +85,7 @@ int CmdStart (

// Update database. An open interval does not need to be flattened.
validate (cli, rules, database, now);
database.addInterval (now);
database.addInterval (now, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (database, rules, now);
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -78,7 +78,7 @@ int CmdStop (

for (auto& interval : flatten (modified, getAllExclusions (rules, modified.range)))
{
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (database, rules, interval);
@@ -103,7 +103,7 @@ int CmdStop (
modified.range.start = modified.range.end;
modified.range.end = {0};
validate (cli, rules, database, modified);
database.addInterval (modified);
database.addInterval (modified, rules.getBoolean ("verbose"));
if (rules.getBoolean ("verbose"))
std::cout << '\n' << intervalSummarize (database, rules, modified);
}
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -70,7 +70,7 @@ int CmdTag (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

dirty = false;
}
@@ -103,7 +103,7 @@ int CmdTag (
i.tag (tag);

//TODO validate (cli, rules, database, i);
database.modifyInterval (tracked[tracked.size () - id], i);
database.modifyInterval (tracked[tracked.size () - id], i, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
{
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -49,7 +49,7 @@ int CmdTrack (

for (auto& interval : flatten (filter, getAllExclusions (rules, filter.range)))
{
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (database, rules, interval);
@@ -34,7 +34,7 @@ static void undoIntervalAction(UndoAction& action, Database& database)
Interval before = Interval::fromJson (action.getBefore ());
Interval after = Interval::fromJson (action.getAfter ());

database.modifyInterval (after, before);
database.modifyInterval (after, before, false);
}

static void undoConfigAction (UndoAction& action, Rules &rules, Database& database)
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -70,7 +70,7 @@ int CmdUntag (
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
database.addInterval (interval, rules.getBoolean ("verbose"));

dirty = false;
}
@@ -103,7 +103,7 @@ int CmdUntag (
i.untag (tag);

// TODO validate (cli, rules, database, i);
database.modifyInterval (tracked[tracked.size () - id], i);
database.modifyInterval (tracked[tracked.size () - id], i, rules.getBoolean ("verbose"));

if (rules.getBoolean ("verbose"))
{
Oops, something went wrong.

0 comments on commit ff7e7b4

Please sign in to comment.