CmdLog: Converted to CLI

This commit is contained in:
Paul Beckingham 2016-04-03 21:31:59 -04:00
parent 63d728af5c
commit ebdf8a944d
4 changed files with 19 additions and 11 deletions

View file

@ -25,23 +25,29 @@
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <Log.h>
#include <commands.h>
#include <shared.h>
#include <vector>
#include <string>
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
// TODO This may be removed, unless it proves useful.
int CmdLog (const std::vector <std::string>& args, Log& log)
int CmdLog (CLI& cli, Log& log)
{
// If no (extra) arguments, simply write a marker.
if (args.size () >= 3 &&
args[2] == "mark")
log.write ("debug", "-------- 8< --------");
auto words = cli.getWords ();
if (words.size ())
{
// 'timew log mark' writes a marker.
if (words[0] == "mark")
log.write ("debug", "-------- 8< --------");
// Othewise write args to the log.
// 'timew log ...' writes '...' to log.
else
log.write ("info", join (" ", words));
}
else
log.write ("info", join (" ", std::vector <std::string> (args.begin () + 2, args.end ())));
std::cout << "No message specified.\n";
return 0;
}

View file

@ -27,6 +27,7 @@
#ifndef INCLUDED_COMMANDS
#define INCLUDED_COMMANDS
#include <CLI.h>
#include <Rules.h>
#include <Database.h>
#include <Extensions.h>
@ -45,7 +46,7 @@ int CmdExtensions ( Rules&, Extensi
int CmdGaps ( );
int CmdHelpUsage ( );
int CmdHelp (const std::vector <std::string>&, Log&);
int CmdLog (const std::vector <std::string>&, Log&);
int CmdLog (CLI&, Log&);
int CmdImport ( );
int CmdReport (const std::vector <std::string>&, Rules&, Database&, Extensions&, Log&);
int CmdStart (const std::vector <std::string>&, Rules&, Database&, Log&);