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
37
src/CLI.cpp
37
src/CLI.cpp
|
@ -27,6 +27,7 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <CLI.h>
|
#include <CLI.h>
|
||||||
#include <Color.h>
|
#include <Color.h>
|
||||||
|
#include <Pig.h>
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -113,13 +114,14 @@ std::string A2::dump () const
|
||||||
std::string tags;
|
std::string tags;
|
||||||
for (auto& tag : _tags)
|
for (auto& tag : _tags)
|
||||||
{
|
{
|
||||||
if (tag == "BINARY") tags += "\033[1;37;44m" + tag + "\033[0m ";
|
if (tag == "BINARY") tags += "\033[1;37;44m" + tag + "\033[0m ";
|
||||||
else if (tag == "CMD") tags += "\033[1;37;46m" + tag + "\033[0m ";
|
else if (tag == "CMD") tags += "\033[1;37;46m" + tag + "\033[0m ";
|
||||||
else if (tag == "EXT") tags += "\033[1;37;42m" + tag + "\033[0m ";
|
else if (tag == "EXT") tags += "\033[1;37;42m" + tag + "\033[0m ";
|
||||||
else if (tag == "HINT") tags += "\033[1;37;43m" + tag + "\033[0m ";
|
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 == "FILTER") tags += "\033[1;37;45m" + tag + "\033[0m ";
|
||||||
else if (tag == "CONFIG") tags += "\033[1;37;101m" + tag + "\033[0m ";
|
else if (tag == "CONFIG") tags += "\033[1;37;101m" + tag + "\033[0m ";
|
||||||
else tags += "\033[32m" + 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 ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return output + " " + atts + tags;
|
return output + " " + atts + tags;
|
||||||
|
@ -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.
|
// Scan all arguments and canonicalize names that need it.
|
||||||
void CLI::canonicalizeNames ()
|
void CLI::canonicalizeNames ()
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
void handleArg0 ();
|
void handleArg0 ();
|
||||||
void lexArguments ();
|
void lexArguments ();
|
||||||
void identifyOverrides ();
|
void identifyOverrides ();
|
||||||
|
void identifyIds ();
|
||||||
void canonicalizeNames ();
|
void canonicalizeNames ();
|
||||||
void identifyFilter ();
|
void identifyFilter ();
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue