mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI
- Added diagnostics only to ::initialize and ::add. - Now properly clears and regenerates all data on change.
This commit is contained in:
parent
7812bce079
commit
d6e11761a6
2 changed files with 32 additions and 17 deletions
40
src/CLI.cpp
40
src/CLI.cpp
|
@ -71,25 +71,48 @@ void CLI::entity (const std::string& name, const std::string& value)
|
||||||
// Capture the original, intact command line arguments.
|
// Capture the original, intact command line arguments.
|
||||||
void CLI::initialize (int argc, const char** argv)
|
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];
|
_program = argv[0];
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
_original_args.push_back (argv[i]);
|
_original_args.push_back (argv[i]);
|
||||||
|
|
||||||
_args = _original_args;
|
_args = _original_args;
|
||||||
|
|
||||||
dump ("CLI::initialize");
|
aliasExpansion ();
|
||||||
extractOverrides ();
|
extractOverrides ();
|
||||||
|
categorize ();
|
||||||
|
|
||||||
|
dump ("CLI::initialize");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI::add (const std::string& arg)
|
void CLI::add (const std::string& arg)
|
||||||
{
|
{
|
||||||
_original_args.push_back (arg);
|
// Clean what needs to be cleaned. Most in this case.
|
||||||
_args.push_back (arg);
|
_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 ();
|
aliasExpansion ();
|
||||||
|
extractOverrides ();
|
||||||
categorize ();
|
categorize ();
|
||||||
|
|
||||||
dump ("CLI::add");
|
dump ("CLI::add");
|
||||||
|
@ -160,11 +183,6 @@ void CLI::categorize ()
|
||||||
{
|
{
|
||||||
bool foundCommand = false;
|
bool foundCommand = false;
|
||||||
|
|
||||||
_filter.clear ();
|
|
||||||
_modifications.clear ();
|
|
||||||
_command = "";
|
|
||||||
_readOnly = false;
|
|
||||||
|
|
||||||
std::vector <std::string>::iterator i;
|
std::vector <std::string>::iterator i;
|
||||||
for (i = _args.begin (); i != _args.end (); ++i)
|
for (i = _args.begin (); i != _args.end (); ++i)
|
||||||
{
|
{
|
||||||
|
@ -182,8 +200,6 @@ void CLI::categorize ()
|
||||||
_filter.push_back (*i);
|
_filter.push_back (*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dump ("CLI::categorize");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -39,16 +39,16 @@ public:
|
||||||
void entity (const std::string&, const std::string&);
|
void entity (const std::string&, const std::string&);
|
||||||
void initialize (int, const char**);
|
void initialize (int, const char**);
|
||||||
void add (const std::string&);
|
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::string getFilter () const;
|
||||||
const std::vector <std::string> getWords () const;
|
const std::vector <std::string> getWords () const;
|
||||||
const std::vector <std::string> getModifications () const;
|
const std::vector <std::string> getModifications () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void aliasExpansion ();
|
||||||
void extractOverrides ();
|
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;
|
void dump (const std::string&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -59,7 +59,6 @@ public:
|
||||||
std::vector <std::string> _args;
|
std::vector <std::string> _args;
|
||||||
std::string _rc;
|
std::string _rc;
|
||||||
std::map <std::string, std::string> _overrides;
|
std::map <std::string, std::string> _overrides;
|
||||||
|
|
||||||
std::string _command;
|
std::string _command;
|
||||||
bool _readOnly;
|
bool _readOnly;
|
||||||
std::vector <std::string> _filter;
|
std::vector <std::string> _filter;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue