- Enabled initial A3t setup, migrating some functionality away from A3.
- Added table of attribute modifiers, for use as parsing entities.
- Context::initialize is now a hybrid of A3 and A3t processing, with the
  transition under way.
This commit is contained in:
Paul Beckingham 2014-04-13 23:57:08 -04:00
parent cf01cc4d02
commit ebd522dfee

View file

@ -44,6 +44,25 @@
#include <commit.h> #include <commit.h>
#endif #endif
// Supported modifiers, synonyms on the same line.
static const char* modifierNames[] =
{
"before", "under", "below",
"after", "over", "above",
"none",
"any",
"is", "equals",
"isnt", "not",
"has", "contains",
"hasnt",
"startswith", "left",
"endswith", "right",
"word",
"noword"
};
#define NUM_MODIFIER_NAMES (sizeof (modifierNames) / sizeof (modifierNames[0]))
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Context::Context () Context::Context ()
: rc_file () : rc_file ()
@ -79,39 +98,20 @@ int Context::initialize (int argc, const char** argv)
try try
{ {
// Assume default .taskrc and .task locations.
assumeLocations ();
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// BEGIN EXPERIMENTAL CODE // BEGIN EXPERIMENTAL CODE
// //
// This experimental section will grow, and the original code below will // This experimental section will grow, and the original code below will
// shrink, and that is how the command line parser will be replaced. // shrink, and this is how the command line parser will be replaced.
// Initialize the command line parser. // Initialize the command line parser.
a3t.initialize (argc, argv); a3t.initialize (argc, argv); // task arg0 arg1 ...
a3t.append_stdin (); // echo stdin0 | task ...
// TODO Uncommenting this breaks unit tests because of the errors it a3t.findFileOverride (); // rc:<file>
// generates. a3t.get_overrides (home_dir, rc_file); // <-- <file>
Tree* parseTree = NULL;
//Tree* parseTree = a3t.parse ();
// END EXPERIMENTAL CODE
////////////////////////////////////////////////////////////////////////////
// char** argv --> std::vector <std::string> Context::a3.
a3.capture (argc, argv);
// echo one two -- three | task zero --> task zero one two
// 'three' is left in the input buffer.
a3.append_stdin ();
// Assume default .taskrc and .task locations.
assumeLocations ();
// Process 'rc:<file>' command line override, and remove the argument from the
// Context::a3.
a3.categorize ();
a3.rc_override (home_dir, rc_file);
// TASKRC environment variable overrides the command line. // TASKRC environment variable overrides the command line.
char* override = getenv ("TASKRC"); char* override = getenv ("TASKRC");
@ -128,9 +128,8 @@ int Context::initialize (int argc, const char** argv)
// The data location, Context::data_dir, is determined from the assumed // The data location, Context::data_dir, is determined from the assumed
// location (~/.task), or set by data.location in the config file, or // location (~/.task), or set by data.location in the config file, or
// overridden by rc.data.location on the command line. // overridden by rc.data.location on the command line.
std::string location; a3t.findConfigOverride (); // rc.<name>[:=]<value>
a3.get_data_location (location); a3t.get_data_location (data_dir); // <-- rc.data.location=<location>
data_dir = Directory (location);
override = getenv ("TASKDATA"); override = getenv ("TASKDATA");
if (override) if (override)
@ -140,6 +139,40 @@ int Context::initialize (int argc, const char** argv)
header (format (STRING_CONTEXT_DATA_OVERRIDE, data_dir._data)); header (format (STRING_CONTEXT_DATA_OVERRIDE, data_dir._data));
} }
// TODO Entities: Reports.
// TODO Entities: Read-only commands.
// TODO Entities: Write commands.
// TODO Entities: Special commands.
// TODO Entities: Helper commands.
// TODO Entities: Attributes (columns).
// Entities: Pseudo-attributes.
a3t.entity ("pseudo", "limit");
// TODO Entities: UDAs.
// Entities: Modifiers.
for (unsigned int i = 0; i < NUM_MODIFIER_NAMES; ++i)
a3t.entity ("modifier", modifierNames[i]);
// TODO Entities: Operators.
// END EXPERIMENTAL CODE
////////////////////////////////////////////////////////////////////////////
// char** argv --> std::vector <std::string> Context::a3.
a3.capture (argc, argv);
// echo one two -- three | task zero --> task zero one two
// 'three' is left in the input buffer.
a3.append_stdin ();
// Process 'rc:<file>' command line override, and remove the argument from the
// Context::a3.
a3.categorize ();
// Create missing config file and data directory, if necessary. // Create missing config file and data directory, if necessary.
a3.apply_overrides (); a3.apply_overrides ();
createDefaultConfig (); createDefaultConfig ();
@ -182,6 +215,11 @@ int Context::initialize (int argc, const char** argv)
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// BEGIN EXPERIMENTAL CODE // BEGIN EXPERIMENTAL CODE
// TODO Uncommenting this breaks unit tests because of the errors it
// generates.
Tree* parseTree = NULL;
//Tree* parseTree = a3t.parse ();
// Initialize the command line parser. // Initialize the command line parser.
if (parseTree && config.getBoolean ("debug")) if (parseTree && config.getBoolean ("debug"))
debug (parseTree->dump ()); debug (parseTree->dump ());
@ -190,7 +228,6 @@ int Context::initialize (int argc, const char** argv)
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// TODO Instantiate extension command objects. // TODO Instantiate extension command objects.
// TODO Instantiate default command object. // TODO Instantiate default command object.