- Added diagnostics only to ::initialize and ::add.
- Now properly clears and regenerates all data on change.
This commit is contained in:
Paul Beckingham 2014-10-14 23:26:12 -04:00
parent 7812bce079
commit d6e11761a6
2 changed files with 32 additions and 17 deletions

View file

@ -71,25 +71,48 @@ void CLI::entity (const std::string& name, const std::string& value)
// Capture the original, intact command line arguments.
void CLI::initialize (int argc, const char** argv)
{
// Clean what needs to be cleaned. Everything in this case.
_program = "";
_original_args.clear ();
_args.clear ();
_rc = "";
_overrides.clear ();
_command = "";
_readOnly = false;
_filter.clear ();
_modifications.clear ();
_program = argv[0];
for (int i = 1; i < argc; ++i)
_original_args.push_back (argv[i]);
_args = _original_args;
dump ("CLI::initialize");
aliasExpansion ();
extractOverrides ();
categorize ();
dump ("CLI::initialize");
}
////////////////////////////////////////////////////////////////////////////////
void CLI::add (const std::string& arg)
{
_original_args.push_back (arg);
_args.push_back (arg);
// Clean what needs to be cleaned. Most in this case.
_program = "";
_args.clear ();
_rc = "";
_overrides.clear ();
_command = "";
_readOnly = false;
_filter.clear ();
_modifications.clear ();
_original_args.push_back (arg);
_args = _original_args;
dump ("CLI::add");
extractOverrides ();
aliasExpansion ();
extractOverrides ();
categorize ();
dump ("CLI::add");
@ -160,11 +183,6 @@ void CLI::categorize ()
{
bool foundCommand = false;
_filter.clear ();
_modifications.clear ();
_command = "";
_readOnly = false;
std::vector <std::string>::iterator i;
for (i = _args.begin (); i != _args.end (); ++i)
{
@ -182,8 +200,6 @@ void CLI::categorize ()
_filter.push_back (*i);
}
}
dump ("CLI::categorize");
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -39,16 +39,16 @@ public:
void entity (const std::string&, const std::string&);
void initialize (int, const char**);
void add (const std::string&);
void aliasExpansion ();
void categorize ();
bool exactMatch (const std::string&, const std::string&) const;
bool canonicalize (std::string&, const std::string&, const std::string&) const;
const std::string getFilter () const;
const std::vector <std::string> getWords () const;
const std::vector <std::string> getModifications () const;
private:
void aliasExpansion ();
void extractOverrides ();
void categorize ();
bool exactMatch (const std::string&, const std::string&) const;
bool canonicalize (std::string&, const std::string&, const std::string&) const;
void dump (const std::string&) const;
public:
@ -59,7 +59,6 @@ public:
std::vector <std::string> _args;
std::string _rc;
std::map <std::string, std::string> _overrides;
std::string _command;
bool _readOnly;
std::vector <std::string> _filter;