A C++17 framework for CLI apps and services. Declare commands and options once in YAML; Drea derives the rest.
- Commands and subcommands (with argument validation)
- Options (typed, validated, with short forms)
- Configuration from multiple sources (file, env, flags, AWS Secrets Manager)
- Logging (spdlog-based, with optional Graylog sink)
--helprendering with a dynamic footer hook- Command groups for tier/role-based gating of help, completion, and execution
manpage generation- Shell completion (
bash,zsh,fish)
commands.yml:
app: say
version: 0.0.1
description: Prints the argument of the command "this" and quits.
options:
- option: reverse
description: reverse string
commands:
- command: this
params-names: string
description: prints the argument
local-options:
- reversemain.cpp:
#include <drea/core/Core>
#include <algorithm>
#include "commands.yml.h"
int main( int argc, char * argv[] )
{
drea::core::App app( argc, argv );
app.parse( std::string( commands_yml, commands_yml + commands_yml_len ) );
app.commander().run( [ &app ]( const std::string & cmd ){
if( cmd == "this" ){
std::string say = app.commander().arguments().front();
if( app.config().used( "reverse" ) ){
std::reverse( say.begin(), say.end() );
}
app.logger().info( "{}", say );
}
});
}$ ./say this hello
[2019-04-16 09:44:44.649] [say] [info] hello
$ ./say this hello --reverse
[2019-04-16 09:44:44.690] [say] [info] ollehDrea ships CMake presets (CMake >= 3.21 + Ninja). Point VCPKG_ROOT at your
vcpkg checkout, then:
cmake --preset debug
cmake --build --preset debug
ctest --preset debugAvailable presets: debug, release, sdk, debug-system, release-system,
sdk-system. The *-system variants use system-installed dependencies
instead of vcpkg.
Opt-in vcpkg features:
cmake --preset debug -DVCPKG_MANIFEST_FEATURES=toml # TOML config files
cmake --preset debug -DVCPKG_MANIFEST_FEATURES=aws # AWS Secrets Manager
cmake --preset debug -DVCPKG_MANIFEST_FEATURES="toml;aws"To enable AWS Secrets Manager at runtime, pass -DENABLE_AWS=ON.
Bare configure (no preset) also works:
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failurefind_package(drea REQUIRED)
target_link_libraries(main PRIVATE drea)- Commands — anatomy, parameters, hierarchy, hiding, groups
- Configuration — options, sources, evaluation order, sensitive values
- Help and shell integration —
--help, dynamic footer,man, completion - API reference —
App,Commander,Config,Command,Option - Examples — index of
examples/
To run the SonarQube scan locally, install build-wrapper and sonar-scanner,
set SONAR_TOKEN, reconfigure CMake (so it picks up sonar-scanner), and:
cmake --build build --target sonarqube