CPGen
C++ project generator
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CLI Class Reference

Stateful command-line parser that converts argv into a Config. More...

#include <CLI.hpp>

Public Member Functions

Config parse (int argc, char **argv)
 Parse command-line arguments into a typed configuration.
 

Detailed Description

Stateful command-line parser that converts argv into a Config.

Each parse call resets the internal ProjectConfig accumulator, so a single CLI instance can safely be reused across multiple test invocations.

Supported flags:

Short Long Description
-h --help Print usage and exit.
-u --tui Return true to trigger TUI mode.
-n --name Project name (must match ^\w +$).
-p --path Target directory (must exist on disk).
-s --std C++ standard: 17, 20, or 23.
-m --modules Comma-separated dependency modules.
-tar --targets Comma-separated target types.
-g --git Enable Git initialisation.
-cf --clang-format Enable clang-format file generation.
-cfp --cf-preset clang-format style preset name.
-ct --clang-tidy Enable clang-tidy file generation.

Member Function Documentation

◆ parse()

Config CLI::parse ( int  argc,
char **  argv 
)

Parse command-line arguments into a typed configuration.

Iterates over argv entries in order and dispatches each recognised flag to the appropriate private helper. Unknown flags are silently skipped.

Parameters
argcNumber of argument strings in argv.
argvNull-terminated array of argument strings (standard C main signature).
Returns
A ProjectConfig if project flags were parsed, or true if --tui was requested.
Exceptions
std::runtime_errorWhen a required flag argument is missing, the path does not exist, or the name does not match the required pattern.
std::range_errorWhen the C++ standard value is not 17, 20, or 23.
Here is the caller graph for this function:

The documentation for this class was generated from the following files: