mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Added ::getWords, done properly
This commit is contained in:
parent
e4ab3574e4
commit
687e7c5e70
2 changed files with 26 additions and 14 deletions
38
src/CLI2.cpp
38
src/CLI2.cpp
|
@ -671,32 +671,44 @@ const std::string CLI2::getFilter (bool applyContext)
|
||||||
context.debug("Derived filter: '" + filter + "'");
|
context.debug("Derived filter: '" + filter + "'");
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Get the original command line arguments, in pristine condition, but skipping:
|
||||||
|
// - BINARY
|
||||||
|
// - CMD
|
||||||
|
// - RC
|
||||||
|
// - CONFIG
|
||||||
|
// - --
|
||||||
const std::vector <std::string> CLI2::getWords ()
|
const std::vector <std::string> CLI2::getWords ()
|
||||||
{
|
{
|
||||||
// Re-analyze the arguments, but do not de-sugar or decompose any. Analysis
|
auto binary = getBinary ();
|
||||||
// only.
|
auto command = getCommand ();
|
||||||
analyze (false);
|
|
||||||
|
|
||||||
// TODO Args that should be extracted as words, should be tagged accordingly,
|
|
||||||
// thereby removing the need for a hard-coded exclusion list.
|
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
for (auto& a : _args)
|
for (auto& a : _original_args)
|
||||||
{
|
{
|
||||||
if (! a.hasTag ("BINARY") &&
|
if (a != binary &&
|
||||||
! a.hasTag ("RC") &&
|
a != command &&
|
||||||
! a.hasTag ("CONFIG") &&
|
a != "--" &&
|
||||||
! a.hasTag ("CMD") &&
|
a.find ("rc:") != 0 &&
|
||||||
! a.hasTag ("TERMINATOR"))
|
a.find ("rc.") != 0)
|
||||||
{
|
{
|
||||||
words.push_back (a.attribute ("raw"));
|
words.push_back (a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
|
{
|
||||||
|
Color colorOrigArgs ("gray10 on gray4");
|
||||||
|
std::string message = " ";
|
||||||
|
for (auto& word : words)
|
||||||
|
message += colorOrigArgs.colorize (word) + " ";
|
||||||
|
context.debug ("CLI2::getWords" + message);
|
||||||
|
}
|
||||||
|
|
||||||
return words;
|
return words;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Search for 'value' in _entities category, return canonicalized value.
|
// Search for 'value' in _entities category, return canonicalized value.
|
||||||
|
|
|
@ -93,8 +93,8 @@ public:
|
||||||
void analyze (bool parse = true, bool strict = false);
|
void analyze (bool parse = true, bool strict = false);
|
||||||
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 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 () const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue