diff --git a/src/Context.cpp b/src/Context.cpp index 1abaf59e0..636b1951b 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include #include #include @@ -127,18 +128,53 @@ void Context::initialize (int argc, char** argv) //////////////////////////////////////////////////////////////////////////////// int Context::run () { - // TODO Dispatch to command handlers. - // TODO Auto shadow update. - // TODO Auto gc. - // TODO tdb.load (Filter); + std::cout << "--- start 1.8.0 ---" << std::endl; + try + { + parse (); - throw std::string ("unimplemented Context::run"); + // TODO Dispatch to command handlers. + // TODO Auto shadow update. + // TODO Auto gc. + // TODO tdb.load (Filter); + } + + catch (const std::string& error) + { + messages.push_back (error); + } + + catch (...) + { + messages.push_back (stringtable.get (100, "Unknown error.")); + } + + // Dump all messages. + foreach (m, messages) + std::cout << *m << std::endl; + + if (footnotes.size ()) + { + std::cout << std::endl; + foreach (f, footnotes) + std::cout << *f << std::endl; + } + + std::cout << "--- end 1.8.0 ---" << std::endl; return 0; } //////////////////////////////////////////////////////////////////////////////// int Context::interactive () { + // TODO init ncurses + // TODO create worker thread + // TODO create refresh thread + + // TODO join refresh thread + // TODO join worker thread + // TODO take down ncurses + throw std::string ("unimplemented Context::interactive"); return 0; } @@ -172,3 +208,10 @@ void Context::loadCorrectConfigFile (int argc, char** argv) } //////////////////////////////////////////////////////////////////////////////// +void Context::parse () +{ + // TODO Replace parse.cpp:parse + throw std::string ("unimplemented Context::parse"); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Context.h b/src/Context.h index eebcaf96f..50b509138 100644 --- a/src/Context.h +++ b/src/Context.h @@ -43,12 +43,16 @@ public: Context& operator= (const Context&); // Assignment operator ~Context (); // Destructor - void initialize (int, char**); - int run (); - int interactive (); + void initialize (int, char**); // all startup + int run (); // task classic + int interactive (); // task interactive (not implemented) + + void message (const std::string&); // Message sink + void footnote (const std::string&); // Footnote sink private: void loadCorrectConfigFile (int, char**); + void parse (); public: Config config; @@ -60,6 +64,8 @@ public: StringTable stringtable; private: + std::vector messages; + std::vector footnotes; }; #endif diff --git a/src/task.cpp b/src/task.cpp index dbb00d3ac..4bd1174f2 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -297,16 +297,9 @@ int main (int argc, char** argv) try { context.initialize (argc, argv); + /* return */ context.run (); - // When redirecting output to a file, do not use color, curses. - if (!isatty (fileno (stdout))) - { - context.config.set ("curses", "off"); - - if (! context.config.get (std::string ("_forcecolor"), false)) - context.config.set ("color", "off"); - } - +// start OBSOLETE TDB tdb; std::string dataLocation = expandPath (context.config.get ("data.location")); tdb.dataDirectory (dataLocation); @@ -342,6 +335,7 @@ int main (int argc, char** argv) std::cerr << context.stringtable.get (100, "Unknown error.") << std::endl; return -2; } +// end OBSOLETE return 0; } diff --git a/src/tests/t2.t.cpp b/src/tests/t2.t.cpp index 68bfb6aac..28490483b 100644 --- a/src/tests/t2.t.cpp +++ b/src/tests/t2.t.cpp @@ -37,10 +37,10 @@ int main (int argc, char** argv) T2 t; t.addTag ("tag1"); t.addTag ("tag2"); - test.is (t.composeF4 (), "[tag:\"tag1&commatag2\" uuid:\"...\"]", "T2::addTag"); + test.is (t.composeF4 (), "[tags:\"tag1,tag2\" uuid:\"...\"]", "T2::addTag"); T2 t2 (t.composeF4 ()); - test.is (t2.composeF4 (), "[tag:\"tag1&commatag2\" uuid:\"...\"]", "T2::composeF4 -> parse round trip"); + test.is (t2.composeF4 (), "[tags:\"tag1,tag2\" uuid:\"...\"]", "T2::composeF4 -> parse round trip"); // Round-trip testing. T2 t3;