https://github.com/nariakiiwatani/ofxCLI
one line editor like command line interface
https://github.com/nariakiiwatani/ofxCLI
Last synced: 4 months ago
JSON representation
one line editor like command line interface
- Host: GitHub
- URL: https://github.com/nariakiiwatani/ofxCLI
- Owner: nariakiiwatani
- License: mit
- Created: 2019-12-01T04:58:08.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-25T08:30:57.000Z (almost 5 years ago)
- Last Synced: 2024-08-01T13:25:17.286Z (7 months ago)
- Language: C++
- Size: 83 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ofxCLI
command line interface for openFrameworks application.
by typing some commands into the window like terminal you can call functions you set.## usage
see example```c++
---
ofApp.h
---
ofx::cli::Prompt prompt_;---
ofApp.cpp
---
// lambda function (with or without capture)
prompt_.subscribe("basic", []() { cout << "basic event occured" << endl; });
// you can set function with arguments
prompt_.subscribe("int2", [](int _0, int _1) { cout << _0 << " " << _1 << endl; });
// you can specify default argument(s)
prompt_.subscribe("str", [](std::string s) { cout << s << endl; }, {"hoge"});
// many parameters...
prompt_.subscribe("many", std::function([](int _0, int _1, int _2, int _3, int _4, int _5, int _6, int _7) {
cout << _0 << " " << _1 << " " << _2 << " " << _3 << " " << _4 << " " << _5 << " " << _6 << " " << _7 << endl;
}), {0,1,2,3,4,5,6,7});
// member function
prompt_.subscribe("some", this, &ofApp::someFunction);
// member function with default arguments
prompt_.subscribe("some2", this, &ofApp::someFunction, {100, 50.3f, "some string"});
// direct binding
prompt_.subscribe("textcolor", text_color_.r, text_color_.g, text_color_.b, text_color_.a);
// (want to write like this but no idea...)
//prompt_.subscribe("textcolor", text_color_);// global function(i don't know how to make this easier...)
prompt_.subscribe("bgcolor", [](float r, float g, float b, float a) {
ofBackground(ofFloatColor(r,g,b,a));
}, {0,0,0,1});
```