-
Notifications
You must be signed in to change notification settings - Fork 27
/
CommandHelp.cpp
61 lines (47 loc) · 1.61 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
53
54
55
56
57
58
59
60
61
/*
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"
namespace cryo {
namespace gpuPlotGenerator {
CommandHelp::CommandHelp(const CommandsMap& p_commands)
: Command("Print this message."), m_commands(p_commands) {
}
CommandHelp::CommandHelp(const CommandHelp& p_command)
: Command(p_command), m_commands(p_command.m_commands) {
}
CommandHelp::~CommandHelp() throw () {
}
void CommandHelp::help() const {
std::cout << "Usage: ./gpuPlotGenerator <command> ..." << std::endl;
std::cout << " Executes the specified command." << std::endl;
std::cout << "Usage: ./gpuPlotGenerator help <command>" << std::endl;
std::cout << " Print the usage and help of the specified command." << std::endl;
std::cout << "Parameters:" << std::endl;
std::cout << " - command: The command name." << std::endl;
std::cout << "Commands:" << std::endl;
for(CommandsMap::const_reference entry : m_commands) {
std::cout << " - " << entry.first << ": " << entry.second->getDescription() << std::endl;
}
}
int CommandHelp::execute(const std::vector<std::string>& p_args) {
if(p_args.size() < 1) {
help();
return 0;
}
std::string command(p_args[0]);
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;
}
}}