-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommandHelp.cpp
52 lines (40 loc) · 1.35 KB
/
CommandHelp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
GPU plot generator for Burst coin.
Author: Cryo
Bitcoin: 138gMBhCrNkbaiTCmUhP9HLU9xwn5QKZgD
Burst: BURST-YA29-QCEW-QXC3-BKXDL
Based on the code of the official miner and dcct's plotgen.
*/
#include <iostream>
#include "CommandHelp.h"
CommandHelp::CommandHelp(const CommandsMap& p_commands)
: Command("Print this message."), m_commands(p_commands) {
}
CommandHelp::CommandHelp(const CommandHelp& p_command)
: Command(p_command.m_description), m_commands(p_command.m_commands) {
}
CommandHelp::~CommandHelp() throw () {
}
void CommandHelp::help() const {
std::cout << "Usage: ./gpuPlotGenerator <command> ..." << std::endl;
std::cout << "Usage: ./gpuPlotGenerator help <command>" << std::endl;
std::cout << "Commands:" << std::endl;
for(CommandsMap::const_iterator it(m_commands.begin()) ; it != m_commands.end() ; ++it) {
std::cout << " - " << it->first << ": " << it->second->getDescription() << std::endl;
}
}
int CommandHelp::execute(const std::vector<std::string>& p_args) {
if(p_args.size() < 2) {
help();
return 0;
}
std::string command(p_args[1]);
if(m_commands.find(command) == m_commands.end()) {
std::cout << "[ERROR] Unknown [" << command << "] command" << std::endl;
std::cout << "----" << std::endl;
help();
return -1;
}
m_commands.at(command)->help();
return 0;
}