Skip to content
Snippets Groups Projects
Martin Wölzer's avatar
Martin Wölzer authored
- bump version to 0.2.0
- updated README.md
- added and updated several tests
- added and updated doc
- updated sample_extractor and added sample_executor
- added clang-format specification
- added support for sanitizers
- added more exhaustive gitlab-pipeline
- added more specific exceptions
- updated help-message generation in parsers (sub_parser, main_parser and basic_parser)
- minor improvements of CMakeLists.txt (e.g. added cppcheck)
- renamed full_example to large_example
- minor improvements to examples
- added test examples scripts
- added build_info_string
- unified arguments and options
259b128f
  _____  _        _____   _____
 / ____|| | __ _ |  __ \ |  __ \
| |     | |/ _` || |__) || |__) |
| |     |_|\__,_||  ___/ |  ___/
| |____          | |     | |
 \_____|         |_|     |_|

libClaPP:

pipeline status coverage report

libClaPP is an open source command line argument processing library for C++. It supports the processing of GNU options (long and short options) as well as positional arguments. It is a strongly typed library that can be used to parse the command line arguments into the correct type, validate the arguments using custom constraints and automatically generates a help message with respect to the types and the constraints.

Build:

Dependencies:

libClaPP only depends on the GSL, but this library is shipped as git-submodule dependency within this git repository.

If the unit tests of this libray should be built, also google test is required (is also shipped as git-submodule dependency). If the listings in the doc/-folder should be extracted and build too, a Raku-(Perl 6)-interpreter is required. A very common Raku interpreter is Rakudo, which can be installed on Debian/Ubuntu by executing apt install rakudo.

Build the library:

Since all build dependencies are already included in this repository as submodules, you may prefer to use the shipped dependencies via the CMake option libClaPP_SUBMODULE_DEPENDENCIES enabled:

git clone --recurse-submodules https://git.libclapp.org/libclapp/clapp.git
mkdir build
cd build
cmake .. -DlibClaPP_SUBMODULE_DEPENDENCIES=On
cmake --build .

Build with system libraries:

But if all dependencies are installed on your system, the following steps are sufficient.

git clone https://git.libclapp.org/libclapp/clapp.git
mkdir build
cd build
cmake ..
cmake --build .

Build the library in debug mode with submodules, unitests and check code coverage:

git clone --recurse-submodules https://git.libclapp.org/libclapp/clapp.git
mkdir build
cd build
cmake -DlibClaPP_BUILD_TESTS=On -DlibClaPP_BUILD_COVERAGE=On -DlibClaPP_SUBMODULE_DEPENDENCIES=On -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
ctest -V -R libclapp_tests
gcovr -r ../ -e ../third_party/ -e ../tests/ -e ../examples/

Build the library in debug mode with submodules, unitests, examples and check code coverage:

git clone --recurse-submodules https://git.libclapp.org/libclapp/clapp.git
mkdir build
cd build
cmake -DlibClaPP_BUILD_TESTS=On -DlibClaPP_BUILD_EXAMPLES=On -DlibClaPP_BUILD_COVERAGE=On -DlibClaPP_SUBMODULE_DEPENDENCIES=On -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
ctest -V -R libclapp_tests
gcovr -r ../ -e ../third_party/ -e ../tests/ -e ../examples/
ctest -V -E libclapp_tests

Build with gcc/clang sanitizers:

LibClaPP can be built with the following sanitizers: Address sanitizer, memory sanitizer, undefined behavior sanitizer or a thread sanitizer. To enable these sanitizers, one of the following options must be set: libClaPP_ENABLE_SANITIZER_ADDRESS, libClaPP_ENABLE_SANITIZER_MEMORY, libClaPP_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR, libClaPP_ENABLE_SANITIZER_THREAD.

For easy switching between different sanitizers, the tool ccmake may be used instead of pure cmake.

Install the library

To install the library on your system, type the following command.

make install

To uninstall the library, remove all files that were installed:

xargs rm < install_manifest.txt

Documentation:

A short documentation of libClaPP is available in doc/doc.md.

Example:

Some examples can be found in the examples folder. Additionally, doc/doc.md also contains a few examples.

For a quick start take a look at examples/short_example.cpp.

Coverage:

cmake -DlibClaPP_BUILD_COVERAGE=On -DCMAKE_BUILD_TYPE=Debug -DlibClaPP_SUBMODULE_DEPENDENCIES=On -DlibClaPP_BUILD_TESTS=On ..
gcovr -r ../ -e ../third_party/ -e ../tests/ -e ../examples/

Clang-Tidy:

CXX=clang++-7 CC=clang-7 cmake -DCLANG_TIDY=clang-tidy-7 -DlibClaPP_BUILD_TESTS=On -DlibClaPP_BUILD_EXAMPLES=On -DlibClaPP_SUBMODULE_DEPENDENCIES=On -DlibClaPP_BUILD_COVERAGE=On -DCMAKE_BUILD_TYPE=Debug -DlibClaPP_CLANG_TIDY=On ..

Clang-Format:

This project uses a clang-format style based on the Google style (clang-format-7 -style=Google -dump-config) but modified a bit (see .clang-format).

To format the whole project, use the following command:

clang-format-7 -i examples/*.cpp examples/*.h examples/*.hpp src/clapp/*.cpp src/include/clapp/*.hpp src/include/clapp/*.h tests/*.cpp tests/*.h tests/*.hpp