mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CLI: Added ::identifyIds
This commit is contained in:
parent
c9af6fa37b
commit
5ee1aa8c9c
2 changed files with 31 additions and 7 deletions
23
src/CLI.cpp
23
src/CLI.cpp
|
@ -27,6 +27,7 @@
|
|||
#include <cmake.h>
|
||||
#include <CLI.h>
|
||||
#include <Color.h>
|
||||
#include <Pig.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <sstream>
|
||||
|
@ -119,6 +120,7 @@ std::string A2::dump () const
|
|||
else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m ";
|
||||
else if (tag == "FILTER") tags += "\033[1;37;45m" + tag + "\033[0m ";
|
||||
else if (tag == "CONFIG") tags += "\033[1;37;101m" + tag + "\033[0m ";
|
||||
else if (tag == "ID") tags += "\033[38;5;7m\033[48;5;34m" + tag + "\033[0m ";
|
||||
else tags += "\033[32m" + tag + "\033[0m ";
|
||||
}
|
||||
|
||||
|
@ -387,6 +389,27 @@ void CLI::identifyOverrides ()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Scan all arguments and identify instances of '@<integer>'.
|
||||
void CLI::identifyIds ()
|
||||
{
|
||||
for (auto& a : _args)
|
||||
{
|
||||
if (a._lextype == Lexer::Type::word)
|
||||
{
|
||||
Pig pig (a.attribute ("raw"));
|
||||
int digits;
|
||||
if (pig.skipLiteral ("@") &&
|
||||
pig.getDigits (digits) &&
|
||||
pig.eos ())
|
||||
{
|
||||
a.tag ("ID");
|
||||
a.attribute ("value", digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Scan all arguments and canonicalize names that need it.
|
||||
void CLI::canonicalizeNames ()
|
||||
|
|
|
@ -70,6 +70,7 @@ private:
|
|||
void handleArg0 ();
|
||||
void lexArguments ();
|
||||
void identifyOverrides ();
|
||||
void identifyIds ();
|
||||
void canonicalizeNames ();
|
||||
void identifyFilter ();
|
||||
bool exactMatch (const std::string&, const std::string&) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue