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 + "'");
|
||||
return filter;
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Get the original command line arguments, in pristine condition, but skipping:
|
||||
// - BINARY
|
||||
// - CMD
|
||||
// - RC
|
||||
// - CONFIG
|
||||
// - --
|
||||
const std::vector <std::string> CLI2::getWords ()
|
||||
{
|
||||
// Re-analyze the arguments, but do not de-sugar or decompose any. Analysis
|
||||
// only.
|
||||
analyze (false);
|
||||
auto binary = getBinary ();
|
||||
auto command = getCommand ();
|
||||
|
||||
// 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;
|
||||
for (auto& a : _args)
|
||||
for (auto& a : _original_args)
|
||||
{
|
||||
if (! a.hasTag ("BINARY") &&
|
||||
! a.hasTag ("RC") &&
|
||||
! a.hasTag ("CONFIG") &&
|
||||
! a.hasTag ("CMD") &&
|
||||
! a.hasTag ("TERMINATOR"))
|
||||
if (a != binary &&
|
||||
a != command &&
|
||||
a != "--" &&
|
||||
a.find ("rc:") != 0 &&
|
||||
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;
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Search for 'value' in _entities category, return canonicalized value.
|
||||
|
|
|
@ -93,8 +93,8 @@ public:
|
|||
void analyze (bool parse = true, bool strict = false);
|
||||
void applyOverrides ();
|
||||
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;
|
||||
std::string getBinary () const;
|
||||
std::string getCommand () const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue