https://github.com/msoeken/alice
C++ command shell library
https://github.com/msoeken/alice
c-plus-plus cli cli-utility pybind11 python
Last synced: 11 months ago
JSON representation
C++ command shell library
- Host: GitHub
- URL: https://github.com/msoeken/alice
- Owner: msoeken
- License: mit
- Created: 2017-11-25T14:44:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T07:28:48.000Z (over 1 year ago)
- Last Synced: 2025-03-24T09:44:41.492Z (11 months ago)
- Topics: c-plus-plus, cli, cli-utility, pybind11, python
- Language: C++
- Homepage:
- Size: 824 KB
- Stars: 51
- Watchers: 7
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/msoeken/alice)
[](https://ci.appveyor.com/project/msoeken/alice)
[](http://libalice.readthedocs.io/en/latest/?badge=latest)
[](https://opensource.org/licenses/MIT)
# alice
alice is a C++-14 command shell library that supports automatic Python bindings. It offers a simple yet feature-rich embedded DSL to create shell interfaces with user-defined commands that access and manipulate arbitrary user-defined data types. Here is a small example for a shell to manipulate `string` objects.
[Read the full documentation.](http://libalice.readthedocs.io/en/latest/?badge=latest)
```c++
#include
#include
#include
#include
namespace alice
{
ALICE_ADD_STORE(std::string, "str", "s", "String", "Strings")
ALICE_PRINT_STORE(std::string, os, element)
{
os << element << std::endl;
}
ALICE_COMMAND(hello, "Generation", "adds a welcome string to the store")
{
auto& strings = store();
strings.extend() = "hello world";
}
ALICE_COMMAND(upper, "Manipulation", "changes string to upper bound")
{
auto& str = store().current();
std::transform( str.begin(), str.end(), str.begin(), ::toupper );
}
}
ALICE_MAIN(demo)
```
After compiling we obtain a shell program with commands that allow us to do the following:
```
demo> hello
demo> print -s
hello world
demo> hello
demo> upper
demo> print -s
HELLO WORLD
demo> current -s 0
demo> print -s
hello world
demo> quit
```
We can use the very same code to compile it into a Python library instead of an executable, allowing us to call the commands as Python methods. For example:
```python
import demo
demo.hello()
demo.upper()
demo.print(str = True)
```
## EPFL logic sythesis libraries
alice is part of the [EPFL logic synthesis](https://lsi.epfl.ch/page-138455-en.html) libraries. The other libraries and several examples on how to use and integrate the libraries can be found in the [logic synthesis tool showcase](https://github.com/lsils/lstools-showcase).