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,10 +4,18 @@
#include <vector>
void Clippy::Run(const std::vector<std::string>& args) {
std::cout << "Hello I'm clippy" << std::endl;
std::cout << "Parametres: { ";
for (size_t i = 0; i < args.size(); ++i) {
std::cout << args[i] << (i + 1 == args.size() ? "" : ",") << " ";
}
std::cout << "}" << std::endl;
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 << "Parametres: { ";
for (size_t i = 0; i < args.size(); ++i) {
std::cout << args[i] << (i + 1 == args.size() ? "" : ",") << " ";
}
std::cout << "}" << std::endl;
}
return false;
}

View file

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