Proof of concept (POC) for creating a command-line interface with C++.
This section provides examples for how to use the CLI (after you install it).
Yarr be the help message.
$ cpp-cli-poc --help
USAGE:
cpp-cli-poc [-h] [--version] {-a|-m|-s} arguments ...
Where:
One of:
-a, --add
finds the sum of a series, a + b + ... + n
-s, --subtract
subtracts a series of numbers, a - b - ... - n
-m, --multiply
multiplies a series of numbers, a * b * ... * n
--, --ignore_rest
Ignores the rest of the labeled arguments following this flag.
--version
Displays version information and exits.
-h, --help
Displays usage information and exits.
arguments (accepted multiple times) <args>
(required) Numbers to operate upon.
Simple proof of concept to demonstrate a command-line interface in C++.One may add numbers...
$ cpp-cli-poc --add 1 2 3 4
10Subtract a series of numbers from an initial value...
$ cpp-cli-poc --subtract 10 4
6
$ cpp-cli-poc --subtract 10 4 3
3Or, multiply a series of numbers...
$ cpp-cli-poc --multiply 1 2 3 4 5
120This project uses cmake, cppcheck, cpplint, and g++ to provide consistent builds.
sudo apt update
sudo apt install cmake g++ cppcheck
sudo python -m pip install cpplintThis project uses Catch2 and includes it as a git submodule. Please initialize the submodule before building the project.
# If you have already cloned the repo...
git submodule update --init --recursive
# If you have yet to clone this repo (and clone using SSH)...
git clone --recurse-submodules -j8 [email protected]:SpaceKatt/cpp-cli-poc.gitA script, auto-build.sh, is provided to automate the build process.
# clean build, generate build system
./clean-build.shOne may also save time by reusing the build system generated in
build/, instead of running the wholeauto-build.shscript everytime.
# reuse compiled libs and build system
./recycle-build.shOnce the CLI builds, we may also install it using the install.sh script.
# install CLI for global bash use (requires sudo)
./install.shCatch2 and CTest are used for testing this project. The aforementioned build script will also build tests if passed the -t flag.
# run tests, after clean build and generating build system
./clean-build.sh -tOne may also save time by reusing the build system generated in
build/, instead of running the wholeauto-build.shscript everytime.
# compile and run tests and reuse compiled libs and build system
./recycle-build.sh -tNOTE:
./recycle-build.sh -twill fail if./clean-build.shis first called without the-tflag.
cppcheck is used for linting the project. A script, ./lint.sh, is provided for ease of use.
# lint project, show warnings, exit 0
./lint.sh
# lint project, exit in error (1) on warnings
./lint.sh -e