add help output

This commit is contained in:
lucaspalomodevelop 2023-10-06 21:41:26 +02:00
parent 52fe8fa52f
commit e3325b1bd3
3 changed files with 17 additions and 4 deletions

View File

@ -41,6 +41,16 @@ public:
this->commands.push_back(command);
}
std::string getHelpAsString()
{
std::string help = "";
for (auto &commandInfo : this->commands)
{
help += commandInfo.name + " - " + commandInfo.description + "\n";
}
return help;
}
void execute(int argc, char *argv[])
{

View File

@ -8,6 +8,9 @@ using namespace lpstd::exceptions;
namespace commands
{
Command &command = Command::Instance();
void add(int argc, char *argv[])
{
std::cout << "add" << std::endl;
@ -53,8 +56,8 @@ namespace commands
void help(int argc, char *argv[])
{
std::cout << "help" << std::endl;
throw NotImplementedException();
// std::cout << "help" << std::endl;
std::cout << command.getHelpAsString() << std::endl;
}
} // namespace commands

View File

@ -3,5 +3,5 @@
#include "./command.h"
#include "./commands.h"
Setup setup;
Command command;
Setup &setup = Setup::Instance();
Command &command = Command::Instance();