Home

Awesome

SLACC - Simple Lightweight Adaptable Command Console

Command console module written in C++11 for use as in-game console module or simple scripting engine.

This module have zero dependencies so it's super easy to use in existing projects. It heavily uses variadic templates to provide automatisation of binding commands with functions and nice API. Small usage example below:

void func1_ptr(const std::string& name) {
    std::cout << "Hello " << name << "!" << std::endl;
}

std::function<void(float)> func2_wrapper = [](float x) {
    std::cout << x << "^2 = " << x*x << std::endl;
};

auto func3_lambda = [](int x, float y, const std::string& z) {
    std::cout << x << y << z << std::endl;
};

/* ... */

CommandConsole cmd;

cmd.bind("func1", func_ptr);      // default parser, types are infered from function pointer
cmd.bind("func2", func2_wrapper); // default parser, types are infered from std::function wrapper
// to use lambda, either wrap it in std::function or provide valid parser
cmd.bind("func3", func3_lambda, Parser::BasicParser::parse<int, float, std::string>);

cmd.execute("func1 John"); // func1_ptr("John")
cmd.execute("func2 11.0"); // func2_wrapper(11.0f)
cmd.execute("func3 0 3.14 \"hello world\""); // func3_lambda(0, 3.14f, "hello world")

Requirements

Platforms tested

Compilers tested

Dependencies

None!

License

See LICENSE file.

Examples of usage

You can find example usage in src/main.cpp file.