CLI: Added ::dump

This commit is contained in:
Paul Beckingham 2016-04-02 15:30:16 -04:00
parent 8913eaf96f
commit ca486d25b8
2 changed files with 31 additions and 0 deletions

View file

@ -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 ();
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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 {};