- Can now safely re-analyze command line if something changes. This required a
  ::analzye method to be called late in Context::initialize.
This commit is contained in:
Paul Beckingham 2014-10-19 17:59:51 -04:00
parent 171fabbcda
commit cd8f7ddac4
3 changed files with 15 additions and 22 deletions

View file

@ -230,30 +230,10 @@ void CLI::initialize (int argc, const char** argv)
{
// Clean what needs to be cleaned. Everything in this case.
_original_args.clear ();
_args.clear ();
for (int i = 0; i < argc; ++i)
{
_original_args.push_back (argv[i]);
if (i == 0)
{
A a ("arg", argv[i]);
a.tag ("ORIGINAL");
a.tag ("BINARY");
_args.push_back (a);
}
else
{
A a ("arg", argv[i]);
a.tag ("ORIGINAL");
_args.push_back (a);
}
}
aliasExpansion ();
findOverrides ();
categorize ();
analyze ();
}
////////////////////////////////////////////////////////////////////////////////
@ -261,9 +241,20 @@ void CLI::initialize (int argc, const char** argv)
void CLI::add (const std::string& arg)
{
// Clean what needs to be cleaned. Most in this case.
_args.clear ();
_original_args.push_back (arg);
analyze ();
}
////////////////////////////////////////////////////////////////////////////////
// Intended to be called after ::initialize() and ::add(), to perform the final
// analysis. Analysis is also performed directly after the above, because there
// is a need to extract overrides early, before entities are proviedd.
void CLI::analyze ()
{
// Clean what needs to be cleaned. Most in this case.
_args.clear ();
for (int i = 0; i < _original_args.size (); ++i)
{
if (i == 0)

View file

@ -66,6 +66,7 @@ public:
void entity (const std::string&, const std::string&);
void initialize (int, const char**);
void add (const std::string&);
void analyze ();
const std::string getFilter ();
const std::vector <std::string> getWords ();
const std::vector <std::string> getModifications ();

View file

@ -248,6 +248,7 @@ int Context::initialize (int argc, const char** argv)
staticInitialization (); // Decouple code from Context.
parser.parse (); // Parse all elements.
cli.analyze (); // Parse all elements.
tdb2.set_location (data_dir); // Prepare the task database.