Skip to main content

ClikaRT::cli

namespace

Classes​

NameDescription
AppThe application root: a command plus the parse/run entry points, version, help/usage/completion text, and injectable output/error streams. Owns the parser; move-only.
ArgA typed option or positional handle. Fluent setters return *this; each configures the underlying declared option through the parser. Non-owning; valid while the owning App lives.
ArgsThe parsed result. Typed reads re-parse the retained token, so the read type is independent of how the option was declared; a wrong-category read returns a failure Result. Owns its state; move-only. Valid while the owning App lives (it references the matched command).
CommandA node in the command tree. Owns nothing itself (a non-owning handle into the App); declares typed options / positionals / flags / subcommands. Options declared on an ancestor resolve from any descendant.
ExclusiveGroupA mutually-exclusive constraint. Lightweight handle, valid while its App lives.
FlagA boolean switch (carries no value). count() on the parsed Args supports -vvv. Non-owning handle, valid while the owning App lives.
GroupA display-only help section. Lightweight handle, valid while its App lives.

Enumerations​

enum ArgType​

enum class ArgType

The value type of an option, fixed where it is declared. One value per parse type: String (verbatim), Int, Float, Bool.

EnumeratorDescription
String
Int
Float
Bool

Declared in ClikaRT/cli/arg.h, line 41

enum Shell​

enum class Shell

Shells App::completion_script can emit.

EnumeratorDescription
Bash
Zsh
Fish

Declared in ClikaRT/cli/arg.h, line 44

Type aliases​

using Validator​

using Validator = std::function<Result<void>(std::string_view value)>

A custom validation callback for an option's value. It runs after the value is parsed at the option's declared type and after choices: given the value as text, return Result<void>; ok() accepts it, a failure rejects the parse and its message is surfaced to the user.

Declared in ClikaRT/cli/arg.h, line 50

using CommandHandler​

using CommandHandler = std::function<Result<int>(Args &)>

A subcommand handler: receives the parsed args, returns a process exit code.

Declared in ClikaRT/cli/command.h, line 40

ClikaRT/cli/arg.h​

#include <ClikaRT/cli/arg.h>

Typed arguments and the parsed-result view for the command-line parser.

An option's type is chosen where it is declared, via ArgType (String / Int / Float / Bool). Values cross the library boundary as strings (defaults, choices, and the parsed tokens are all text), and typed reads come back as Result<T> (Args::get_int / get_float / get_bool / get_string). This keeps the public ABI free of templates and matches the parser's own store-raw-string / re-parse-on-read model.

Arg and Flag are lightweight, non-owning handles: the parser owns the declared option; the handle just names it for fluent configuration and is valid while its owning App lives.

ClikaRT/cli/command.h​

#include <ClikaRT/cli/command.h>

The command / application surface: Command (a node in the command tree), the group handles Group (display-only) and ExclusiveGroup (mutually-exclusive constraint), and App (the root: parse/run, version, help, completion). Every fallible call returns Result and the parser never throws or exits.

cli::App app("clika-modelverse", "the model zoo");
app.version("0.1");
app.flag("-v", "--verbose").help("chatty");
app.add("--revision", cli::ArgType::String).default_value("main");
app.positional("source", cli::ArgType::String);
int rc = app.run(argc, argv);