- Added '_show' command to generate a machine-readable configuration settings
  list for use by third-party software (thanks to Jake Bell).
This commit is contained in:
Paul Beckingham 2012-11-17 12:45:44 -05:00
parent 973e0ed56b
commit 92c3f0862d
8 changed files with 49 additions and 1 deletions

View file

@ -438,3 +438,33 @@ int CmdShow::execute (std::string& output)
}
////////////////////////////////////////////////////////////////////////////////
CmdShowRaw::CmdShowRaw ()
{
_keyword = "_show";
_usage = "task _show";
_description = STRING_CMD_SHOWRAW;
_read_only = true;
_displays_id = false;
}
////////////////////////////////////////////////////////////////////////////////
int CmdShowRaw::execute (std::string& output)
{
// Get all the settings.
std::vector <std::string> all;
context.config.all (all);
// Sort alphabetically by name.
std::sort (all.begin (), all.end ());
// Display them all.
std::vector <std::string>::iterator i;
std::stringstream out;
for (i = all.begin (); i != all.end (); ++i)
out << *i << '=' << context.config.get (*i) << "\n";
output = out.str ();
return 0;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -39,5 +39,12 @@ public:
int execute (std::string&);
};
class CmdShowRaw : public Command
{
public:
CmdShowRaw ();
int execute (std::string&);
};
#endif
////////////////////////////////////////////////////////////////////////////////

View file

@ -154,6 +154,7 @@ void Command::factory (std::map <std::string, Command*>& all)
c = new CmdReports (); all[c->keyword ()] = c;
c = new CmdShell (); all[c->keyword ()] = c;
c = new CmdShow (); all[c->keyword ()] = c;
c = new CmdShowRaw (); all[c->keyword ()] = c;
c = new CmdStart (); all[c->keyword ()] = c;
c = new CmdStats (); all[c->keyword ()] = c;
c = new CmdStop (); all[c->keyword ()] = c;