Command Line INterpreter with fixes
This commit is contained in:
parent
62cb2bb8b7
commit
576a3565f7
14 changed files with 384 additions and 95 deletions
34
CommandLine/tests/TestInterpreter.cpp
Normal file
34
CommandLine/tests/TestInterpreter.cpp
Normal 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();
|
||||
}
|
||||
|
|
@ -12,7 +12,8 @@ int main() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
testCommandLine();
|
||||
// testCommandLine();
|
||||
testInterpreter();
|
||||
|
||||
testModule.deinitialize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,3 +5,4 @@
|
|||
#include "CommandLine.hpp"
|
||||
|
||||
void testCommandLine();
|
||||
void testInterpreter();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue