MCPcopy Create free account
hub / github.com/Mixaill/FakePDB / Run

Method Run

src_cpp/src/main.cpp:30–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 int Run(int argc, char* argv[]) {
31 if (argc < 2) {
32 Usage();
33 return 0;
34 }
35
36 std::string command_name = argv[1];
37 for (auto& command : _commands) {
38 //check name
39 if (command->GetCommandName() != command_name) {
40 continue;
41 }
42
43 //check arg count
44 if (argc-2 < command->GetArgsMin() || argc-2 > command->GetArgsMax()) {
45 std::cerr << "Invalid number of arguments" << std::endl;
46 for (auto& usage : command->GetCommandUsage()) {
47 std::cout << "Usage : " << command->GetCommandName() << " " << usage << std::endl;
48 }
49 }
50
51 //run
52 return command->Run(argc, argv);
53 }
54
55 std::cerr << "Command not found" << std::endl;
56 Usage();
57 return 1;
58 }
59
60 void Usage() {
61 std::cout << "Available commands" << std::endl << std::endl;

Callers 1

mainFunction · 0.45

Calls 4

GetCommandNameMethod · 0.45
GetArgsMinMethod · 0.45
GetArgsMaxMethod · 0.45
GetCommandUsageMethod · 0.45

Tested by

no test coverage detected