mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CLI: Added ::dump
This commit is contained in:
parent
8913eaf96f
commit
ca486d25b8
2 changed files with 31 additions and 0 deletions
30
src/CLI.cpp
30
src/CLI.cpp
|
@ -27,6 +27,7 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <CLI.h>
|
#include <CLI.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <Color.h>
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -158,3 +159,32 @@ bool CLI::canonicalize (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::string CLI::dump (const std::string& title) const
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
|
||||||
|
out << "\033[1m" << title << "\033[0m\n"
|
||||||
|
<< " _original_args\n ";
|
||||||
|
|
||||||
|
Color colorArgs ("gray10 on gray4");
|
||||||
|
for (auto i = _original_args.begin (); i != _original_args.end (); ++i)
|
||||||
|
{
|
||||||
|
if (i != _original_args.begin ())
|
||||||
|
out << ' ';
|
||||||
|
|
||||||
|
out << colorArgs.colorize (i->attribute ("raw"));
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "\n";
|
||||||
|
|
||||||
|
if (_args.size ())
|
||||||
|
{
|
||||||
|
out << " _args\n";
|
||||||
|
for (const auto& a : _args)
|
||||||
|
out << " " << a.dump () << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.str ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
void entity (const std::string&, const std::string&);
|
void entity (const std::string&, const std::string&);
|
||||||
void add (const std::string&);
|
void add (const std::string&);
|
||||||
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
||||||
|
const std::string dump (const std::string& title = "CLI Parser") const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::multimap <std::string, std::string> _entities {};
|
std::multimap <std::string, std::string> _entities {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue