diff --git a/src/command.h b/src/command.h index c6d35e8..1fdc14e 100644 --- a/src/command.h +++ b/src/command.h @@ -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[]) { diff --git a/src/commands.h b/src/commands.h index 25c487f..5281062 100644 --- a/src/commands.h +++ b/src/commands.h @@ -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 diff --git a/src/main.h b/src/main.h index 77dfbeb..a38ec79 100644 --- a/src/main.h +++ b/src/main.h @@ -3,5 +3,5 @@ #include "./command.h" #include "./commands.h" -Setup setup; -Command command; \ No newline at end of file +Setup &setup = Setup::Instance(); +Command &command = Command::Instance(); \ No newline at end of file