Command Line INterpreter with fixes

This commit is contained in:
IlushaShurupov 2023-07-19 21:29:57 +03:00 committed by Ilya Shurupov
parent 32c7512b69
commit 58db6fe058
14 changed files with 384 additions and 95 deletions

View file

@ -0,0 +1,34 @@
#include "Tests.hpp"
#include "CmdLineInterpreter.hpp"
using namespace tp;
TEST_DEF_STATIC(Simple) {
struct TestStruct {
int val = 0;
static bool print(TestStruct* self, const CommandLine& args) {
printf("Test Val - %i\n", (int) args.getBool("bool"));
return false;
}
};
TestStruct self;
CmdLineInterpreter interp;
interp.addCommand("test", new CommandLine{ { "bool", CommandLine::Arg::BOOL } }, (CmdLineInterpreter::CommandFunction) TestStruct::print);
printf("test false\n", stdin);
printf("help\n", stdin);
printf("help test\n", stdin);
printf("exit\n", stdin);
interp.run();
}
TEST_DEF(Interpreter) {
//testSimple();
}

View file

@ -12,7 +12,8 @@ int main() {
return 1;
}
testCommandLine();
// testCommandLine();
testInterpreter();
testModule.deinitialize();
}

View file

@ -5,3 +5,4 @@
#include "CommandLine.hpp"
void testCommandLine();
void testInterpreter();