A basic command line app with REPL using the cli11 library
This project add the REPL (Read Evaluate Print Loop) functionality to the basic cli app demo.
Extended notes on the concepts explored are discussed here.
The app demonstrates among other concepts a simple sentence level parsing.
The app simulates a fictitious zoo which has only CATs, DOGs and PENGUINs!
REPL mode: This is activated when the app is executed without any flag or option i.e. $ app
.
It drops to the app's REPL console <app> _
<app> help()
: shows a brief description of the app.<app> list()
: lists the available animals and possible actions/operations.<app> cat walk
: issues a command that an animal: cat should perform an action: walk.<app> exit()
: will exit the app.
Non-REPL mode: when you add a flag or option
- list the available animals:
$ app -l
- list all possible operations/actions by an animal:
$ app -l -a "cat"
- Make an animal perform an action:
$ app -a "cat" -o "talk"
- Show app version:
$ app --version
- Show help:
$ app --help
- Pass in a file of animal and action:
$ app -i data.txt
OR$ app data.txt
sample content of data.txt:cat walk dog talk penguin swim
I have only utilised the basic functionalities of the cli11 library. It is quite powerful, helping to lift the boilerplate of handling command line args. I have used the LLVM's command line tool, but I prefer the cli11 library to it. The only downside is that is not llvm stuff, which matters if you plan to upstream into llvm.
- Command Line handling using a robust library like the cli11 library
- Basic design of a REPL app and very basic parsing.
- Basic software design of a cli app with both REPL and normal mode.
Like
$ python my_ai.py
versus$ python
which drops you to>>>_
- Some C++ OOP stuff
- CMakeList file: Top-level and Test with gtest cmake setup
- MakeFile (not used)
- Travis CI yaml file
- Basic Dockerised C++ app: the Dockerfile and the script to build and run it.
Just clone and to build run this script: . ./run.sh
To build and run in docker use this: . ./docker-run.sh
The name is app, see above for sample usage. REPL mode: $ app
. Non-REPL mode: $./app --help