mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-06 17:37:21 +02:00
Enhancements - Context integration
- Context now gathers messages and footnotes. - task now calls into the new 1.8.0 code (via Context), then calls into the old 1.7.0 code. Two for the price of one.
This commit is contained in:
parent
024986fe88
commit
54f155f439
4 changed files with 62 additions and 19 deletions
|
@ -25,6 +25,7 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -127,18 +128,53 @@ void Context::initialize (int argc, char** argv)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Context::run ()
|
int Context::run ()
|
||||||
{
|
{
|
||||||
// TODO Dispatch to command handlers.
|
std::cout << "--- start 1.8.0 ---" << std::endl;
|
||||||
// TODO Auto shadow update.
|
try
|
||||||
// TODO Auto gc.
|
{
|
||||||
// TODO tdb.load (Filter);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Context::interactive ()
|
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");
|
throw std::string ("unimplemented Context::interactive");
|
||||||
return 0;
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -43,12 +43,16 @@ public:
|
||||||
Context& operator= (const Context&); // Assignment operator
|
Context& operator= (const Context&); // Assignment operator
|
||||||
~Context (); // Destructor
|
~Context (); // Destructor
|
||||||
|
|
||||||
void initialize (int, char**);
|
void initialize (int, char**); // all startup
|
||||||
int run ();
|
int run (); // task classic
|
||||||
int interactive ();
|
int interactive (); // task interactive (not implemented)
|
||||||
|
|
||||||
|
void message (const std::string&); // Message sink
|
||||||
|
void footnote (const std::string&); // Footnote sink
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadCorrectConfigFile (int, char**);
|
void loadCorrectConfigFile (int, char**);
|
||||||
|
void parse ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config config;
|
Config config;
|
||||||
|
@ -60,6 +64,8 @@ public:
|
||||||
StringTable stringtable;
|
StringTable stringtable;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector <std::string> messages;
|
||||||
|
std::vector <std::string> footnotes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
12
src/task.cpp
12
src/task.cpp
|
@ -297,16 +297,9 @@ int main (int argc, char** argv)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
context.initialize (argc, argv);
|
context.initialize (argc, argv);
|
||||||
|
/* return */ context.run ();
|
||||||
|
|
||||||
// When redirecting output to a file, do not use color, curses.
|
// start OBSOLETE
|
||||||
if (!isatty (fileno (stdout)))
|
|
||||||
{
|
|
||||||
context.config.set ("curses", "off");
|
|
||||||
|
|
||||||
if (! context.config.get (std::string ("_forcecolor"), false))
|
|
||||||
context.config.set ("color", "off");
|
|
||||||
}
|
|
||||||
|
|
||||||
TDB tdb;
|
TDB tdb;
|
||||||
std::string dataLocation = expandPath (context.config.get ("data.location"));
|
std::string dataLocation = expandPath (context.config.get ("data.location"));
|
||||||
tdb.dataDirectory (dataLocation);
|
tdb.dataDirectory (dataLocation);
|
||||||
|
@ -342,6 +335,7 @@ int main (int argc, char** argv)
|
||||||
std::cerr << context.stringtable.get (100, "Unknown error.") << std::endl;
|
std::cerr << context.stringtable.get (100, "Unknown error.") << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
// end OBSOLETE
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@ int main (int argc, char** argv)
|
||||||
T2 t;
|
T2 t;
|
||||||
t.addTag ("tag1");
|
t.addTag ("tag1");
|
||||||
t.addTag ("tag2");
|
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 ());
|
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.
|
// Round-trip testing.
|
||||||
T2 t3;
|
T2 t3;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue