Cleanup: Replaced "\n" with '\n'

This commit is contained in:
Paul Beckingham 2016-04-23 13:30:54 -04:00
parent 9e6ee03354
commit 49715320ef
20 changed files with 151 additions and 151 deletions

View file

@ -335,13 +335,13 @@ std::string CLI::dump (const std::string& title) const
out << colorArgs.colorize (i->attribute ("raw")); out << colorArgs.colorize (i->attribute ("raw"));
} }
out << "\n"; out << '\n';
if (_args.size ()) if (_args.size ())
{ {
out << " _args\n"; out << " _args\n";
for (auto& a : _args) for (auto& a : _args)
out << " " << a.dump () << "\n"; out << " " << a.dump () << '\n';
} }
return out.str (); return out.str ();

View file

@ -166,7 +166,7 @@ std::string Database::dump () const
std::stringstream out; std::stringstream out;
out << "Database\n"; out << "Database\n";
for (auto& exclusion : _exclusions) for (auto& exclusion : _exclusions)
out << " Exclusion: " << exclusion << "\n"; out << " Exclusion: " << exclusion << '\n';
for (auto& df : _files) for (auto& df : _files)
out << df.dump (); out << df.dump ();

View file

@ -154,7 +154,7 @@ void Datafile::commit ()
// Write out all the lines. // Write out all the lines.
for (auto& line : _lines) for (auto& line : _lines)
_file.write_raw (line + "\n"); _file.write_raw (line + '\n');
_file.close (); _file.close ();
_dirty = false; _dirty = false;
@ -169,13 +169,13 @@ std::string Datafile::dump () const
{ {
std::stringstream out; std::stringstream out;
out << "Datafile\n" out << "Datafile\n"
<< " Name: " << _file.name () << (_file.exists () ? "" : " (does not exist)") << "\n" << " Name: " << _file.name () << (_file.exists () ? "" : " (does not exist)") << '\n'
<< " dirty: " << (_dirty ? "true" : "false") << "\n" << " dirty: " << (_dirty ? "true" : "false") << '\n'
<< " lines: " << _lines.size () << "\n" << " lines: " << _lines.size () << '\n'
<< " loaded " << (_lines_loaded ? "true" : "false") << "\n" << " loaded " << (_lines_loaded ? "true" : "false") << '\n'
<< " exclusions: " << _exclusions.size () << "\n" << " exclusions: " << _exclusions.size () << '\n'
<< " range: " << _range.start.toISO () << " - " << " range: " << _range.start.toISO () << " - "
<< _range.end.toISO () << "\n"; << _range.end.toISO () << '\n';
return out.str (); return out.str ();
} }

View file

@ -148,7 +148,7 @@ std::string Exclusion::serialize () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Exclusion::dump () const std::string Exclusion::dump () const
{ {
return std::string ("Exclusion ") + join (" ", _tokens) + "\n"; return std::string ("Exclusion ") + join (" ", _tokens) + '\n';
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -68,11 +68,11 @@ int Extensions::callExtension (
{ {
if (_debug) if (_debug)
{ {
std::cout << "Extension: Calling " << script << "\n" std::cout << "Extension: Calling " << script << '\n'
<< "Extension: input"; << "Extension: input";
for (auto& i : input) for (auto& i : input)
std::cout << " " << i << "\n"; std::cout << " " << i << '\n';
} }
auto inputStr = join ("\n", input); auto inputStr = join ("\n", input);
@ -94,7 +94,7 @@ int Extensions::callExtension (
output = split (outputStr, '\n'); output = split (outputStr, '\n');
if (_debug) if (_debug)
std::cout << "Extension: Completed with status " << status << "\n"; std::cout << "Extension: Completed with status " << status << '\n';
return status; return status;
} }
@ -106,7 +106,7 @@ std::string Extensions::dump () const
out << "Extensions\n"; out << "Extensions\n";
for (auto& script : _scripts) for (auto& script : _scripts)
out << " " << script << "\n"; out << " " << script << '\n';
return out.str (); return out.str ();
} }

View file

@ -170,11 +170,11 @@ std::string Rules::dump () const
std::stringstream out; std::stringstream out;
out << "Rules\n" out << "Rules\n"
<< " _original_file " << _original_file << " _original_file " << _original_file
<< "\n"; << '\n';
out << " Settings\n"; out << " Settings\n";
for (auto& item : _settings) for (auto& item : _settings)
out << " " << item.first << "=" << item.second << "\n"; out << " " << item.first << "=" << item.second << '\n';
return out.str (); return out.str ();
} }
@ -212,7 +212,7 @@ void Rules::parse (const std::string& input, int nest /* = 1 */)
} }
else else
{ {
ruleDef += line + "\n"; ruleDef += line + '\n';
} }
} }
@ -235,7 +235,7 @@ void Rules::parse (const std::string& input, int nest /* = 1 */)
} }
inRule = true; inRule = true;
ruleDef = line + "\n"; ruleDef = line + '\n';
} }
// Top-level import: // Top-level import:

View file

@ -117,7 +117,7 @@ std::string Timeline::dump () const
{ {
std::stringstream out; std::stringstream out;
out << "Timeline range " << range.dump () << "\n"; out << "Timeline range " << range.dump () << '\n';
for (auto& i : _inclusions) for (auto& i : _inclusions)
out << " " << i.json (); out << " " << i.json ();
for (auto& e : _exclusions) for (auto& e : _exclusions)

View file

@ -68,9 +68,9 @@ int CmdDiagnostics (
const Extensions& extensions) const Extensions& extensions)
{ {
std::stringstream out; std::stringstream out;
out << "\n" out << '\n'
<< PACKAGE_STRING << PACKAGE_STRING
<< "\n"; << '\n';
out << " Platform: " << osName () out << " Platform: " << osName ()
<< "\n\n"; << "\n\n";
@ -78,7 +78,7 @@ int CmdDiagnostics (
// Compiler. // Compiler.
out << "Compiler:\n" out << "Compiler:\n"
#ifdef __VERSION__ #ifdef __VERSION__
<< " Version: " << __VERSION__ << "\n" << " Version: " << __VERSION__ << '\n'
#endif #endif
<< " Caps:" << " Caps:"
#ifdef __STDC__ #ifdef __STDC__
@ -107,7 +107,7 @@ int CmdDiagnostics (
<< " +l" << 8 * sizeof (long) << " +l" << 8 * sizeof (long)
<< " +vp" << 8 * sizeof (void*) << " +vp" << 8 * sizeof (void*)
<< " +time_t" << 8 * sizeof (time_t) << " +time_t" << 8 * sizeof (time_t)
<< "\n"; << '\n';
// Compiler compliance level. // Compiler compliance level.
std::string compliance = "non-compliant"; std::string compliance = "non-compliant";
@ -127,11 +127,11 @@ int CmdDiagnostics (
out << "Build Features\n" out << "Build Features\n"
// Build date. // Build date.
<< " Built: " << __DATE__ << " " << __TIME__ << "\n" << " Built: " << __DATE__ << " " << __TIME__ << '\n'
#ifdef HAVE_COMMIT #ifdef HAVE_COMMIT
<< " Commit: " << COMMIT << "\n" << " Commit: " << COMMIT << '\n'
#endif #endif
<< " CMake: " << CMAKE_VERSION << "\n"; << " CMake: " << CMAKE_VERSION << '\n';
out << " Build type: " out << " Build type: "
#ifdef CMAKE_BUILD_TYPE #ifdef CMAKE_BUILD_TYPE
@ -152,37 +152,37 @@ int CmdDiagnostics (
<< ", mode " << ", mode "
<< std::setbase (8) << std::setbase (8)
<< context.config._original_file.mode () << context.config._original_file.mode ()
<< "\n"; << '\n';
*/ */
char* env = getenv ("TIMEWARRIORDB"); char* env = getenv ("TIMEWARRIORDB");
out << " TIMEWARRIORDB: " out << " TIMEWARRIORDB: "
<< (env ? env : "-") << (env ? env : "-")
<< "\n"; << '\n';
File cfg (rules.get ("temp.db") + "/timewarrior.cfg"); File cfg (rules.get ("temp.db") + "/timewarrior.cfg");
out << " Cfg: " << describeFile (cfg) << "\n"; out << " Cfg: " << describeFile (cfg) << '\n';
Directory db (rules.get ("temp.db")); Directory db (rules.get ("temp.db"));
out << " Database: " << describeFile (db) << "\n"; out << " Database: " << describeFile (db) << '\n';
for (auto& file : database.files ()) for (auto& file : database.files ())
{ {
File df (rules.get ("temp.db") + "/data"); File df (rules.get ("temp.db") + "/data");
df += file; df += file;
out << " " << describeFile (df) << "\n"; out << " " << describeFile (df) << '\n';
} }
// Determine rc.editor/$EDITOR/$VISUAL. // Determine rc.editor/$EDITOR/$VISUAL.
char* peditor; char* peditor;
if ((peditor = getenv ("VISUAL")) != NULL) if ((peditor = getenv ("VISUAL")) != NULL)
out << " $VISUAL: " << peditor << "\n"; out << " $VISUAL: " << peditor << '\n';
else if ((peditor = getenv ("EDITOR")) != NULL) else if ((peditor = getenv ("EDITOR")) != NULL)
out << " $EDITOR: " << peditor << "\n"; out << " $EDITOR: " << peditor << '\n';
// Theme description, if present. // Theme description, if present.
if (rules.has ("theme.description")) if (rules.has ("theme.description"))
out << " Color theme: " << rules.get ("theme.description") << "\n"; out << " Color theme: " << rules.get ("theme.description") << '\n';
else else
out << " Color theme: Default theme\n"; out << " Color theme: Default theme\n";
@ -196,17 +196,17 @@ int CmdDiagnostics (
out << "\n "; out << "\n ";
out << ' ' << palette.next ().colorize (rightJustifyZero (color, 2)); out << ' ' << palette.next ().colorize (rightJustifyZero (color, 2));
} }
out << "\n"; out << '\n';
} }
out << "\n"; out << '\n';
// Display extensions. // Display extensions.
Directory extDir (rules.get ("temp.db")); Directory extDir (rules.get ("temp.db"));
extDir += "extensions"; extDir += "extensions";
out << "Extensions\n" out << "Extensions\n"
<< " Location: " << describeFile (extDir) << "\n"; << " Location: " << describeFile (extDir) << '\n';
auto exts = extensions.all (); auto exts = extensions.all ();
if (exts.size ()) if (exts.size ())
@ -224,13 +224,13 @@ int CmdDiagnostics (
out << " "; out << " ";
out.width (longest); out.width (longest);
out << describeFile (file) << "\n"; out << describeFile (file) << '\n';
} }
} }
else else
out << " (None)\n"; out << " (None)\n";
out << "\n"; out << '\n';
std::cout << out.str (); std::cout << out.str ();
return 0; return 0;

View file

@ -65,12 +65,12 @@ int CmdExtensions (
Directory extDir (rules.get ("temp.db")); Directory extDir (rules.get ("temp.db"));
extDir += "extensions"; extDir += "extensions";
std::cout << "\n" std::cout << '\n'
<< "Extensions located in:\n" << "Extensions located in:\n"
<< " " << extDir._data << "\n" << " " << extDir._data << '\n'
<< "\n" << '\n'
<< t.render () << t.render ()
<< "\n"; << '\n';
return 0; return 0;
} }

View file

@ -32,7 +32,7 @@
int CmdHelpUsage () int CmdHelpUsage ()
{ {
// TODO This is going to need formatting. // TODO This is going to need formatting.
std::cout << "\n" std::cout << '\n'
<< "Usage: timew [--version]\n" << "Usage: timew [--version]\n"
<< " timew continue\n" << " timew continue\n"
<< " timew diagnostics\n" << " timew diagnostics\n"
@ -44,7 +44,7 @@ int CmdHelpUsage ()
<< " timew stop [<tag> ...]\n" << " timew stop [<tag> ...]\n"
<< " timew tags\n" << " timew tags\n"
<< " timew track <interval> [<tag> ...]\n" << " timew track <interval> [<tag> ...]\n"
<< "\n" << '\n'
<< "Interval:\n" << "Interval:\n"
<< " [from] <date>\n" << " [from] <date>\n"
<< " [from] <date> to/- <date>\n" << " [from] <date> to/- <date>\n"
@ -52,13 +52,13 @@ int CmdHelpUsage ()
<< " <duration> before <date>\n" << " <duration> before <date>\n"
<< " <duration> after <date>\n" << " <duration> after <date>\n"
<< " <duration>\n" << " <duration>\n"
<< "\n" << '\n'
<< "Tag:\n" << "Tag:\n"
<< " Word\n" << " Word\n"
<< " 'Single Quoted Words'\n" << " 'Single Quoted Words'\n"
<< " \"Double Quoted Words\"\n" << " \"Double Quoted Words\"\n"
<< " Escaped\\ Spaces\n" << " Escaped\\ Spaces\n"
<< "\n"; << '\n';
// TODO clear // TODO clear
// TODO config // TODO config
@ -99,109 +99,109 @@ int CmdHelp (const CLI& cli)
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
if (words[0] == "continue") if (words[0] == "continue")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew continue\n" << "Syntax: timew continue\n"
<< "\n" << '\n'
<< "Resumes tracking the most recently closed interval. For exqample:\n" << "Resumes tracking the most recently closed interval. For exqample:\n"
<< "\n" << '\n'
<< " $ timew track 9am - 5pm tag1 tag2\n" << " $ timew track 9am - 5pm tag1 tag2\n"
<< " $ timew continue\n" << " $ timew continue\n"
<< "\n" << '\n'
<< "The 'continue' command creates a new interval, starting now, and using the tags\n" << "The 'continue' command creates a new interval, starting now, and using the tags\n"
<< "'tag1' and 'tag2'.\n" << "'tag1' and 'tag2'.\n"
<< "\n" << '\n'
<< "See also 'start', 'stop'.\n" << "See also 'start', 'stop'.\n"
<< "\n"; << '\n';
// TODO day // TODO day
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "diagnostics") else if (words[0] == "diagnostics")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew diagnostics\n" << "Syntax: timew diagnostics\n"
<< "\n" << '\n'
<< "This command shows details about your version of Timewarrior, platform, how it\n" << "This command shows details about your version of Timewarrior, platform, how it\n"
<< "was built, compiler features, configuration, file access, extensions and more.\n" << "was built, compiler features, configuration, file access, extensions and more.\n"
<< "\n" << '\n'
<< "The purpose of this command is to help diagnose configuration problems, and\n" << "The purpose of this command is to help diagnose configuration problems, and\n"
<< "provide supplemental information when reporting a problem.\n" << "provide supplemental information when reporting a problem.\n"
<< "\n" << '\n'
<< "See also 'extensions'.\n" << "See also 'extensions'.\n"
<< "\n"; << '\n';
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "export") else if (words[0] == "export")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew export [<interval>] [<tag> ...]\n" << "Syntax: timew export [<interval>] [<tag> ...]\n"
<< "\n" << '\n'
<< "Exports all the tracked time in JSON format. Supports filtering. For example:\n" << "Exports all the tracked time in JSON format. Supports filtering. For example:\n"
<< "\n" << '\n'
<< " $ timew export from 2016-01-01 for 3wks tag1\n" << " $ timew export from 2016-01-01 for 3wks tag1\n"
<< "\n" << '\n'
<< "See also 'import'.\n" << "See also 'import'.\n"
<< "\n"; << '\n';
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "extensions") else if (words[0] == "extensions")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew extensions\n" << "Syntax: timew extensions\n"
<< "\n" << '\n'
<< "Displays the directory containing the extension programs, and a table showing\n" << "Displays the directory containing the extension programs, and a table showing\n"
<< "each extensions and its status.\n" << "each extensions and its status.\n"
<< "\n" << '\n'
<< "See also 'diagnostics'.\n" << "See also 'diagnostics'.\n"
<< "\n"; << '\n';
// TODO gaps // TODO gaps
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "help") else if (words[0] == "help")
std::cout << "\n" std::cout << '\n'
<< "The help command shows detailed descriptions and examples of commands and the\n" << "The help command shows detailed descriptions and examples of commands and the\n"
<< "supported hints. For example:\n" << "supported hints. For example:\n"
<< "\n" << '\n'
<< " $ timew help\n" << " $ timew help\n"
<< " $ timew help start\n" << " $ timew help start\n"
<< " $ timew help hints\n" << " $ timew help hints\n"
<< "\n"; << '\n';
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "hints") else if (words[0] == "hints")
std::cout << "\n" std::cout << '\n'
<< "Timewarrior supports hints, which are single-word command line features that\n" << "Timewarrior supports hints, which are single-word command line features that\n"
<< "start with a colon like this:\n" << "start with a colon like this:\n"
<< "\n" << '\n'
<< " :week\n" << " :week\n"
<< "\n" << '\n'
<< "Hints serve several purposes. This example is a shortcut for the date range\n" << "Hints serve several purposes. This example is a shortcut for the date range\n"
<< "that defines the current week. Other hints, such as:\n" << "that defines the current week. Other hints, such as:\n"
<< "\n" << '\n'
<< " :quiet\n" << " :quiet\n"
<< "\n" << '\n'
<< "are ways to control the behavior of Timewarrior, in this case eliminating all\n" << "are ways to control the behavior of Timewarrior, in this case eliminating all\n"
<< "forms of feedback, for purposes of automation. The supported hints are:\n" << "forms of feedback, for purposes of automation. The supported hints are:\n"
<< "\n" << '\n'
<< " :quiet Turns off all feedback. For automation\n" << " :quiet Turns off all feedback. For automation\n"
<< " :debug Runs in debug mode, shows many runtime details\n" << " :debug Runs in debug mode, shows many runtime details\n"
<< "\n" << '\n'
<< " :color Force color on, even if not connected to a TTY\n" << " :color Force color on, even if not connected to a TTY\n"
<< " :nocolor Force color off, even if connected to a TTY\n" << " :nocolor Force color off, even if connected to a TTY\n"
<< "\n" << '\n'
<< " :yesterday The 24 hours of the previous day\n" << " :yesterday The 24 hours of the previous day\n"
<< " :day The 24 hours of the current day\n" << " :day The 24 hours of the current day\n"
<< " :week This week\n" << " :week This week\n"
<< " :month This month\n" << " :month This month\n"
<< " :quarter This quarter\n" << " :quarter This quarter\n"
<< " :year This year\n" << " :year This year\n"
<< "\n" << '\n'
<< " :fill Expand time to fill surrounding available gap\n" << " :fill Expand time to fill surrounding available gap\n"
<< " Only functions when exclusions are provided\n" << " Only functions when exclusions are provided\n"
<< "\n"; << '\n';
// TODO import // TODO import
// TODO month // TODO month
@ -211,57 +211,57 @@ int CmdHelp (const CLI& cli)
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "start") else if (words[0] == "start")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew start [<date>] [<tag> ...]\n" << "Syntax: timew start [<date>] [<tag> ...]\n"
<< "\n" << '\n'
<< "Begins tracking using the current time, and the specified optional set of tags.\n" << "Begins tracking using the current time, and the specified optional set of tags.\n"
<< "If a tag contains multiple words, and therefore contains spaces, use quotes to\n" << "If a tag contains multiple words, and therefore contains spaces, use quotes to\n"
<< "surround the whole tag. For example, this command specifies two tags ('weekend'\n" << "surround the whole tag. For example, this command specifies two tags ('weekend'\n"
<< "and 'Home & Garden'), the second of which requires quotes.\n" << "and 'Home & Garden'), the second of which requires quotes.\n"
<< "\n" << '\n'
<< " $ timew start weekend 'Home & Garden'\n" << " $ timew start weekend 'Home & Garden'\n"
<< "\n" << '\n'
<< "An optional date may be specified to indicate the intended start to the tracked\n" << "An optional date may be specified to indicate the intended start to the tracked\n"
<< "time:\n" << "time:\n"
<< "\n" << '\n'
<< " $ time start 8am weekend 'Home & Garden'\n" << " $ time start 8am weekend 'Home & Garden'\n"
<< "\n" << '\n'
<< "Quotes are harmless if used unecessarily.\n" << "Quotes are harmless if used unecessarily.\n"
<< "\n" << '\n'
<< "See also 'continue', 'stop', 'track'.\n" << "See also 'continue', 'stop', 'track'.\n"
<< "\n"; << '\n';
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "stop") else if (words[0] == "stop")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew stop [<tag> ...]\n" << "Syntax: timew stop [<tag> ...]\n"
<< "\n" << '\n'
<< "Stops tracking time. If tags are specified, then they are no longer tracked.\n" << "Stops tracking time. If tags are specified, then they are no longer tracked.\n"
<< "If no tags are specified, all tracking stops. For example:\n" << "If no tags are specified, all tracking stops. For example:\n"
<< "\n" << '\n'
<< " $ timew start tag1 tag2\n" << " $ timew start tag1 tag2\n"
<< " ...\n" << " ...\n"
<< " $ timew stop tag1\n" << " $ timew stop tag1\n"
<< "\n" << '\n'
<< "Initially time is tracked for both 'tag1' and 'tag2', then 'tag1' tracking is\n" << "Initially time is tracked for both 'tag1' and 'tag2', then 'tag1' tracking is\n"
<< "stopped, leaving tag2 active. To stop all tracking:\n" << "stopped, leaving tag2 active. To stop all tracking:\n"
<< "\n" << '\n'
<< " $ timew stop\n" << " $ timew stop\n"
<< "\n" << '\n'
<< "See also 'continue', 'start', 'track'.\n" << "See also 'continue', 'start', 'track'.\n"
<< "\n"; << '\n';
// TODO summary // TODO summary
// Ruler 1 2 3 4 5 6 7 8 // Ruler 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "tags") else if (words[0] == "tags")
std::cout << "\n" std::cout << '\n'
<< "Syntax: timew tags\n" << "Syntax: timew tags\n"
<< "\n" << '\n'
<< "Displays all the tags that have been used.\n" << "Displays all the tags that have been used.\n"
<< "\n"; << '\n';
// TODO track // TODO track
// TODO undo // TODO undo

View file

@ -97,10 +97,10 @@ int CmdReport (
std::stringstream header; std::stringstream header;
for (auto& name : rules.all ()) for (auto& name : rules.all ())
header << name << ": " << rules.get (name) << "\n"; header << name << ": " << rules.get (name) << '\n';
auto input = header.str () auto input = header.str ()
+ "\n" + '\n'
+ jsonFromIntervals (intervals); + jsonFromIntervals (intervals);
// Run the extensions. // Run the extensions.
@ -109,7 +109,7 @@ int CmdReport (
// Display the output. // Display the output.
for (auto& line : output) for (auto& line : output)
std::cout << line << "\n"; std::cout << line << '\n';
return 0; return 0;
} }

View file

@ -63,20 +63,20 @@ int CmdReportDay (
// TODO Axis, hard-coded. // TODO Axis, hard-coded.
std::string indent = " "; std::string indent = " ";
std::cout << "\n" std::cout << '\n'
<< indent << indent
<< "0 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11\n"; << "0 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11\n";
// TODO Data, missing. // TODO Data, missing.
std::cout << "\n" std::cout << '\n'
<< "\n"; << '\n';
// TODO Summary, missing. // TODO Summary, missing.
std::cout << "\n" std::cout << '\n'
<< indent << "Tracked\n" << indent << "Tracked\n"
<< indent << "Untracked\n" << indent << "Untracked\n"
<< indent << "Total\n" << indent << "Total\n"
<< "\n"; << '\n';
return 0; return 0;
} }

View file

@ -71,14 +71,14 @@ int CmdStop (
// User feedback. // User feedback.
if (rules.getBoolean ("verbose")) if (rules.getBoolean ("verbose"))
std::cout << "\n" << intervalSummarize (rules, latest); std::cout << '\n' << intervalSummarize (rules, latest);
} }
} }
else else
{ {
std::string message = "There is no active time tracking."; std::string message = "There is no active time tracking.";
if (rules.getBoolean ("verbose")) if (rules.getBoolean ("verbose"))
std::cout << message << "\n"; std::cout << message << '\n';
} }
return 0; return 0;

View file

@ -68,9 +68,9 @@ int CmdTags (Rules& rules, Database& database)
t.set (row, 1, rules.has (name) ? rules.get (name) : "-"); t.set (row, 1, rules.has (name) ? rules.get (name) : "-");
} }
std::cout << "\n" std::cout << '\n'
<< t.render () << t.render ()
<< "\n"; << '\n';
} }
else else
std::cout << "No data found.\n"; std::cout << "No data found.\n";

View file

@ -67,21 +67,21 @@ std::string intervalSummarize (const Rules& rules, const Interval& interval)
if (interval.range.ended ()) if (interval.range.ended ())
{ {
Duration dur (Datetime (interval.range.end) - Datetime (interval.range.start)); Duration dur (Datetime (interval.range.end) - Datetime (interval.range.start));
out << "Recorded " << tags << "\n" out << "Recorded " << tags << '\n'
<< " Started " << interval.range.start.toISOLocalExtended () << "\n" << " Started " << interval.range.start.toISOLocalExtended () << '\n'
<< " Ended " << interval.range.end.toISOLocalExtended () << "\n" << " Ended " << interval.range.end.toISOLocalExtended () << '\n'
<< " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << "\n"; << " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << '\n';
} }
// Interval open. // Interval open.
else else
{ {
Duration dur (Datetime () - interval.range.start); Duration dur (Datetime () - interval.range.start);
out << "Tracking " << tags << "\n" out << "Tracking " << tags << '\n'
<< " Started " << interval.range.start.toISOLocalExtended () << "\n"; << " Started " << interval.range.start.toISOLocalExtended () << '\n';
if (dur.toTime_t () > 10) if (dur.toTime_t () > 10)
out << " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << "\n"; out << " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << '\n';
} }
} }
@ -390,7 +390,7 @@ std::string jsonFromIntervals (const std::vector <Interval>& intervals)
} }
if (counter) if (counter)
out << "\n"; out << '\n';
out << "]\n"; out << "]\n";
return out.str (); return out.str ();

View file

@ -46,7 +46,7 @@ bool lightweightVersionCheck (int argc, const char** argv)
{ {
if (argc == 2 && std::string (argv[1]) == "--version") if (argc == 2 && std::string (argv[1]) == "--version")
{ {
std::cout << VERSION << "\n"; std::cout << VERSION << '\n';
return true; return true;
} }
@ -232,7 +232,7 @@ int dispatchCommand (
// Debug output. // Debug output.
if (rules.getBoolean ("debug")) if (rules.getBoolean ("debug"))
std::cout << cli.dump () << "\n"; std::cout << cli.dump () << '\n';
// Dispatch to the right command function. // Dispatch to the right command function.
std::string command = cli.getCommand (); std::string command = cli.getCommand ();

View file

@ -13,7 +13,7 @@ int main (int argc, char** argv)
std::string token; std::string token;
Lexer::Type type; Lexer::Type type;
while (l.token (token, type)) while (l.token (token, type))
std::cout << " token '" << token << "' " << Lexer::typeToString (type) << "\n"; std::cout << " token '" << token << "' " << Lexer::typeToString (type) << '\n';
} }
} }

View file

@ -85,21 +85,21 @@ int main (int argc, const char** argv)
catch (const std::string& error) catch (const std::string& error)
{ {
std::cerr << error << "\n"; std::cerr << error << '\n';
status = -1; status = -1;
} }
catch (std::bad_alloc& error) catch (std::bad_alloc& error)
{ {
auto message = std::string ("Memory allocation failed: ") + error.what (); auto message = std::string ("Memory allocation failed: ") + error.what ();
std::cerr << "Error: " << message << "\n"; std::cerr << "Error: " << message << '\n';
status = -3; status = -3;
} }
catch (...) catch (...)
{ {
auto message = "Unknown problem, please report."; auto message = "Unknown problem, please report.";
std::cerr << "Error: " << message << "\n"; std::cerr << "Error: " << message << '\n';
status = -2; status = -2;
} }

View file

@ -59,7 +59,7 @@ int main (int, char**)
tokens.clear (); tokens.clear ();
while (l3.token (token, type)) while (l3.token (token, type))
{ {
std::cout << "# «" << token << "» " << Lexer::typeName (type) << "\n"; std::cout << "# «" << token << "» " << Lexer::typeName (type) << '\n';
tokens.push_back (std::pair <std::string, Lexer::Type> (token, type)); tokens.push_back (std::pair <std::string, Lexer::Type> (token, type));
} }

View file

@ -51,7 +51,7 @@ UnitTest::UnitTest (int planned)
, _failed (0) , _failed (0)
, _skipped (0) , _skipped (0)
{ {
std::cout << "1.." << _planned << "\n"; std::cout << "1.." << _planned << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -99,14 +99,14 @@ void UnitTest::plan (int planned)
_failed = 0; _failed = 0;
_skipped = 0; _skipped = 0;
std::cout << "1.." << _planned << "\n"; std::cout << "1.." << _planned << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void UnitTest::planMore (int extra) void UnitTest::planMore (int extra)
{ {
_planned += extra; _planned += extra;
std::cout << "1.." << _planned << "\n"; std::cout << "1.." << _planned << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -122,7 +122,7 @@ void UnitTest::ok (bool expression, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -132,7 +132,7 @@ void UnitTest::ok (bool expression, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
} }
@ -149,7 +149,7 @@ void UnitTest::notok (bool expression, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -159,7 +159,7 @@ void UnitTest::notok (bool expression, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
} }
@ -175,7 +175,7 @@ void UnitTest::is (bool actual, bool expected, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -189,7 +189,7 @@ void UnitTest::is (bool actual, bool expected, const std::string& name)
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -205,7 +205,7 @@ void UnitTest::is (size_t actual, size_t expected, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -219,7 +219,7 @@ void UnitTest::is (size_t actual, size_t expected, const std::string& name)
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -235,7 +235,7 @@ void UnitTest::is (int actual, int expected, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -249,7 +249,7 @@ void UnitTest::is (int actual, int expected, const std::string& name)
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -265,7 +265,7 @@ void UnitTest::is (double actual, double expected, const std::string& name)
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -279,7 +279,7 @@ void UnitTest::is (double actual, double expected, const std::string& name)
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -295,7 +295,7 @@ void UnitTest::is (double actual, double expected, double tolerance, const std::
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -309,7 +309,7 @@ void UnitTest::is (double actual, double expected, double tolerance, const std::
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -325,7 +325,7 @@ void UnitTest::is (unsigned char actual, unsigned char expected, const std::stri
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -339,7 +339,7 @@ void UnitTest::is (unsigned char actual, unsigned char expected, const std::stri
<< expected << expected
<< "\n# got: " << "\n# got: "
<< actual << actual
<< "\n"; << '\n';
} }
} }
@ -358,7 +358,7 @@ void UnitTest::is (
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -392,7 +392,7 @@ void UnitTest::is (
<< _counter << _counter
<< " - " << " - "
<< name << name
<< "\n"; << '\n';
} }
else else
{ {
@ -418,7 +418,7 @@ void UnitTest::diag (const std::string& text)
auto end = text.find_last_not_of (" \t\n\r\f"); auto end = text.find_last_not_of (" \t\n\r\f");
if (start != std::string::npos && if (start != std::string::npos &&
end != std::string::npos) end != std::string::npos)
std::cout << "# " << text.substr (start, end - start + 1) << "\n"; std::cout << "# " << text.substr (start, end - start + 1) << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -431,7 +431,7 @@ void UnitTest::pass (const std::string& text)
<< _counter << _counter
<< " - " << " - "
<< text << text
<< "\n"; << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -444,7 +444,7 @@ void UnitTest::fail (const std::string& text)
<< _counter << _counter
<< " - " << " - "
<< text << text
<< "\n"; << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -457,7 +457,7 @@ void UnitTest::skip (const std::string& text)
<< _counter << _counter
<< " - " << " - "
<< text << text
<< "\n"; << '\n';
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////