Add help option

This commit is contained in:
Timofey 2022-08-10 11:04:37 +03:00
parent 6cc47ac543
commit b9d951ec9a
2 changed files with 15 additions and 6 deletions

View file

@ -4,6 +4,11 @@
#include <vector> #include <vector>
void Clippy::Run(const std::vector<std::string>& args) { void Clippy::Run(const std::vector<std::string>& args) {
TryExecuteClippyCommand(args);
}
bool Clippy::TryExecuteClippyCommand(const std::vector<std::string>& args) {
if (args.size() >= 2 && (args[1] == "help" || args[1] == "hello")) {
std::cout << "Hello I'm clippy" << std::endl; std::cout << "Hello I'm clippy" << std::endl;
std::cout << "Parametres: { "; std::cout << "Parametres: { ";
for (size_t i = 0; i < args.size(); ++i) { for (size_t i = 0; i < args.size(); ++i) {
@ -11,3 +16,6 @@ void Clippy::Run(const std::vector<std::string>& args) {
} }
std::cout << "}" << std::endl; std::cout << "}" << std::endl;
} }
return false;
}

View file

@ -8,4 +8,5 @@ class Clippy {
void Run(const std::vector<std::string>& args); void Run(const std::vector<std::string>& args);
private: private:
bool TryExecuteClippyCommand(const std::vector<std::string>& args);
}; };