mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Added ::getWords and ::getCommand variations
- ::getWords (false) now returns an unfiltered list of command line args, specifically any rc.<name>:<value> or rc:<file> args are left uninterpreted. - ::getCommand (false) now returns the raw command, not the canonical command.
This commit is contained in:
parent
cbf20217dc
commit
12825c5205
2 changed files with 13 additions and 21 deletions
27
src/CLI2.cpp
27
src/CLI2.cpp
|
@ -680,11 +680,11 @@ const std::string CLI2::getFilter (bool applyContext)
|
||||||
// - RC
|
// - RC
|
||||||
// - CONFIG
|
// - CONFIG
|
||||||
// - --
|
// - --
|
||||||
const std::vector <std::string> CLI2::getWords ()
|
const std::vector <std::string> CLI2::getWords (bool filtered)
|
||||||
{
|
{
|
||||||
auto binary = getBinary ();
|
auto binary = getBinary ();
|
||||||
auto command = getCommand ();
|
auto command = getCommand ();
|
||||||
auto commandRaw = getCommandRaw ();
|
auto commandRaw = getCommand (false);
|
||||||
|
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
for (auto& a : _original_args)
|
for (auto& a : _original_args)
|
||||||
|
@ -692,13 +692,16 @@ const std::vector <std::string> CLI2::getWords ()
|
||||||
if (a != binary &&
|
if (a != binary &&
|
||||||
a != command &&
|
a != command &&
|
||||||
a != commandRaw &&
|
a != commandRaw &&
|
||||||
a != "--" &&
|
a != "--")
|
||||||
a.find ("rc:") != 0 &&
|
{
|
||||||
a.find ("rc.") != 0)
|
if (! filtered ||
|
||||||
|
(a.find ("rc:") != 0 &&
|
||||||
|
a.find ("rc.") != 0))
|
||||||
{
|
{
|
||||||
words.push_back (a);
|
words.push_back (a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (context.config.getInteger ("debug.parser") >= 3)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
{
|
{
|
||||||
|
@ -755,21 +758,11 @@ std::string CLI2::getBinary () const
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string CLI2::getCommand () const
|
std::string CLI2::getCommand (bool canonical) const
|
||||||
{
|
{
|
||||||
for (auto& a : _args)
|
for (auto& a : _args)
|
||||||
if (a.hasTag ("CMD"))
|
if (a.hasTag ("CMD"))
|
||||||
return a.attribute ("canonical");
|
return a.attribute (canonical ? "canonical" : "raw");
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
std::string CLI2::getCommandRaw () const
|
|
||||||
{
|
|
||||||
for (auto& a : _args)
|
|
||||||
if (a.hasTag ("CMD"))
|
|
||||||
return a.attribute ("raw");
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,11 +94,10 @@ public:
|
||||||
void applyOverrides ();
|
void applyOverrides ();
|
||||||
const std::string getFilter (bool applyContext = true);
|
const std::string getFilter (bool applyContext = true);
|
||||||
*/
|
*/
|
||||||
const std::vector <std::string> getWords ();
|
const std::vector <std::string> getWords (bool filtered = true);
|
||||||
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
||||||
std::string getBinary () const;
|
std::string getBinary () const;
|
||||||
std::string getCommand () const;
|
std::string getCommand (bool canonical = true) const;
|
||||||
std::string getCommandRaw () const;
|
|
||||||
/*
|
/*
|
||||||
std::string getLimit () const;
|
std::string getLimit () const;
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue