32 lines
754 B
C++
Executable File
32 lines
754 B
C++
Executable File
#include "Help.h"
|
|
#include "server/sparkd/cmds/CmdRegistry.h"
|
|
#include <iostream>
|
|
|
|
namespace bts {
|
|
namespace cmd {
|
|
|
|
int Help::execute(std::vector<std::string> const &args)
|
|
{
|
|
auto commands = CmdRegistry::cmds ();
|
|
if (args.size () != 1 || CmdRegistry::retrieve (args[0]) == 0) {
|
|
std::cerr << "Syntax: sparkd <cmd> <args> or sparkd help <cmd>, where cmd is one of: "
|
|
<< std::endl;
|
|
|
|
for (auto &cmd : commands)
|
|
std::cerr << "\t" << cmd << std::endl;
|
|
return 0;
|
|
} else {
|
|
auto cmd = CmdRegistry::retrieve (args[0]);
|
|
std::cerr << "sparkd " << args[0] << ":" << std::endl << cmd->help () << std::endl;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
std::string Help::help ()
|
|
{
|
|
return "Display help.";
|
|
}
|
|
|
|
}}
|
|
|