CmdDefine: Converted to CLI

This commit is contained in:
Paul Beckingham 2016-04-03 22:02:52 -04:00
parent 6e6cab5f70
commit 5f2774c723
3 changed files with 7 additions and 7 deletions

View file

@ -44,20 +44,20 @@
// timew define tag <tag> color <color> // timew define tag <tag> color <color>
// //
int CmdDefine ( int CmdDefine (
const std::vector <std::string>& args, CLI& cli,
Rules& rules, Rules& rules,
Database& database, Database& database,
Log& log) Log& log)
{ {
if (args.size () >= 3 && auto words = cli.getWords ();
closeEnough ("define", args[1], 3)) if (words.size () >= 1)
{ {
std::vector <std::string> subcommands = {"holidays", "week", "day", "tag"}; std::vector <std::string> subcommands = {"holidays", "week", "day", "tag"};
std::vector <std::string> matches; std::vector <std::string> matches;
autoComplete (args[2], subcommands, matches); autoComplete (words[0], subcommands, matches);
if (matches.size () != 1) if (matches.size () != 1)
throw format ("Unrecognized definition '{1}'.", args[2]); throw format ("Unrecognized definition '{1}'.", words[0]);
if (matches[0] == "holidays") if (matches[0] == "holidays")
{ {

View file

@ -39,7 +39,7 @@ int CmdClear ( );
int CmdConfig ( ); int CmdConfig ( );
int CmdContinue ( Rules&, Database&, Log&); int CmdContinue ( Rules&, Database&, Log&);
int CmdDefault ( Rules&, Database& ); int CmdDefault ( Rules&, Database& );
int CmdDefine (const std::vector <std::string>&, Rules&, Database&, Log&); int CmdDefine (CLI&, Rules&, Database&, Log&);
int CmdDiagnostics ( Rules&, Database&, Extensions&, Log&); int CmdDiagnostics ( Rules&, Database&, Extensions&, Log&);
int CmdExport (CLI&, Rules&, Database&, Log&); int CmdExport (CLI&, Rules&, Database&, Log&);
int CmdExtensions ( Rules&, Extensions& ); int CmdExtensions ( Rules&, Extensions& );

View file

@ -215,7 +215,7 @@ int dispatchCommand (
if (command == "clear") status = CmdClear ( ); if (command == "clear") status = CmdClear ( );
else if (command == "config") status = CmdConfig ( ); else if (command == "config") status = CmdConfig ( );
else if (command == "continue") status = CmdContinue ( rules, database, log); else if (command == "continue") status = CmdContinue ( rules, database, log);
else if (command == "define") status = CmdDefine (args, rules, database, log); else if (command == "define") status = CmdDefine (cli, rules, database, log);
else if (command == "diagnostics") status = CmdDiagnostics ( rules, database, extensions, log); else if (command == "diagnostics") status = CmdDiagnostics ( rules, database, extensions, log);
else if (command == "export") status = CmdExport (cli, rules, database, log); else if (command == "export") status = CmdExport (cli, rules, database, log);
else if (command == "extensions") status = CmdExtensions ( rules, extensions ); else if (command == "extensions") status = CmdExtensions ( rules, extensions );