AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
AnCH CLI library documentation

Introduction

AnCH CLI library aims to provide facilities for parsing CLI arguments and CLI formatter

Prerequisites

AnCH CLI is a standalone library for now

Installation

make install

Conception

AnCH CLI library main class is: ArgHandler.
AnCH CLI library contains common bindings in cli/utils.hpp .

Examples

Generate and parse CLIs:

App application = {
.name = "toto",
.version = "0.1 alpha 42",
.author = "Vincent Lachenal",
.copyright = "No copyrigth - it is a fuking unit test",
.licence = "WTFPL 2.0",
.banner = "Ceci est une bannière",
.bannerPath = "/etc/fstab"
};
// Application options are declared ...
Options opts;
{
ArgHandler handler(application, {
{.handler = anch::cli::bindTrue(opts.verbose), .sopt = 'v', .lopt = "verbose", .description = "Verbose mode"},
{.handler = anch::cli::bindStr(opts.str), .sopt = 'p', .lopt = "plop", .value = true, .name = "trestreslong", .description = "plop arg", .example = "PLOP!!!"},
{.handler = anch::cli::bindStr(opts.str2), .lopt = "plip", .value = true, .description = "plip arg"},
{.handler = anch::cli::bindStr(opts.pos), .value = true, .name = "POS1", .description = "pos"},
{.handler = anch::cli::bindStr(opts.pos2), .value = true, .name = "POS2", .description = "pos2"},
{.handler = anch::cli::bindCol(opts.multPos), .value = true, .name = "POSM", .multi = true, .description = "pos-mult"}
});
handler.printBanner(std::cerr);
handler.handle(argc, argv);
}