Skip to content

Repository files navigation

cppcli

A C++23 command-line application and reusable library for converting JSON, XML, YAML, and TOML.

Usage

Convert a file:

cppcli convert --from json --to yaml input.json

Read from standard input:

printf'{"name":"Ada"}'| cppcli convert --from json --to toml

XML uses a natural mapping: object keys become element names, repeated elements become arrays, attributes use @-prefixed keys, and mixed text uses #text. When an object cannot provide one document element, XML output uses <root>.

TOML output requires an object at the document root and rejects null values because TOML cannot represent them.

Library

Each format is an independent class derived from cppcli::Format. Interfaces call cppcli::convert(input, input_format, output_format), so adding another format only requires a class implementing name(), parse(), and serialize(). Register an instance in format_for() only when the CLI should recognize its name.

Build

Enter the Nix development shell to obtain Premake, the compiler, and libraries:

nix develop
premake5 gmake
bear -- make -C build -B config=release
./build/bin/Release/cppcli --help

Bear writes compile_commands.json, allowing clangd to resolve the core include path and Nix-provided libraries.

Run the package directly with nix run -- convert ..., or build it with nix build.

Tests

make -C build config=debug
./build/bin/Debug/cppcli-tests

About

An example c++ CLI app

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages