From 3b332eb96c6c278fa22ff15f010138f0aeafff39 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 2 Mar 2016 08:15:57 -0500 Subject: [PATCH] CmdDefine: Rules object propagated to the command --- src/commands/CmdDefine.cpp | 3 ++- src/commands/commands.h | 4 +++- src/init.cpp | 4 ++-- src/timew.cpp | 4 ++-- src/timew.h | 4 +++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/commands/CmdDefine.cpp b/src/commands/CmdDefine.cpp index ba384d70..f17fb389 100644 --- a/src/commands/CmdDefine.cpp +++ b/src/commands/CmdDefine.cpp @@ -25,10 +25,11 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include #include //////////////////////////////////////////////////////////////////////////////// -int CmdDefine () +int CmdDefine (Rules& rules) { std::cout << "# define\n"; return 0; diff --git a/src/commands/commands.h b/src/commands/commands.h index 041aba6a..77efd7b0 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -27,9 +27,11 @@ #ifndef INCLUDED_COMMANDS #define INCLUDED_COMMANDS +#include + int CmdClear (); int CmdDefault (); -int CmdDefine (); +int CmdDefine (Rules&); int CmdExport (); int CmdExtension (); int CmdHelp (); diff --git a/src/init.cpp b/src/init.cpp index d7d1d5d7..b18ea1f2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -32,7 +32,7 @@ #include // TODO Remove //////////////////////////////////////////////////////////////////////////////// -int dispatchCommand (int argc, const char** argv) +int dispatchCommand (int argc, const char** argv, Rules& rules) { int status {0}; @@ -52,7 +52,7 @@ int dispatchCommand (int argc, const char** argv) // command to fn mapping. if (closeEnough (allCommands[0], argv[1], 2)) status = CmdHelp (); else if (closeEnough (allCommands[1], argv[1], 2)) status = CmdClear (); - else if (closeEnough (allCommands[2], argv[1], 2)) status = CmdDefine (); + else if (closeEnough (allCommands[2], argv[1], 2)) status = CmdDefine (rules); else if (closeEnough (allCommands[3], argv[1], 2)) status = CmdExport (); else if (closeEnough (allCommands[4], argv[1], 2)) status = CmdImport (); else if (closeEnough (allCommands[5], argv[1], 2)) status = CmdReport (); diff --git a/src/timew.cpp b/src/timew.cpp index b9ee321e..97b75b61 100644 --- a/src/timew.cpp +++ b/src/timew.cpp @@ -89,8 +89,8 @@ int main (int argc, const char** argv) // TODO Load rules. // TODO Parse rules. - // TODO Dispatch to commands. - status = dispatchCommand (argc, argv); + // Dispatch to commands. + status = dispatchCommand (argc, argv, rules); } catch (const std::string& error) diff --git a/src/timew.h b/src/timew.h index adf9eb61..0db22c5f 100644 --- a/src/timew.h +++ b/src/timew.h @@ -27,8 +27,10 @@ #ifndef INCLUDED_TIMEW #define INCLUDED_TIMEW +#include + // init.cpp -int dispatchCommand (int, const char**); +int dispatchCommand (int, const char**, Rules&); #endif