ReXGlue SDK
Loading...
Searching...
No Matches
rex::CLIArgList Class Reference

#include <rex/cli.h>

Public Member Functions

bool Has (std::string_view name) const
std::optional< std::string_view > Get (std::string_view name) const
std::span< const CLIOption > GetOptions () const
std::span< const std::string > GetPositionals () const
std::span< const std::string > GetAll () const

Static Public Member Functions

static CLIArgList Parse (i32 argc, char **argv)
static CLIArgList Parse (std::span< const std::string > args)

Detailed Description

The command line, split into options and positional arguments. An option is –name or –name=value, and a token after –name that does not start with – is its value.

Member Function Documentation

◆ Get()

std::optional< std::string_view > rex::CLIArgList::Get ( std::string_view name) const

Reads the value of an option.

Parameters
nameOption name without the leading dashes.
Returns
The value given as –name=value or –name value, or std::nullopt when the option is absent or has no value.

◆ GetAll()

std::span< const std::string > rex::CLIArgList::GetAll ( ) const
Returns
The arguments in their original order, without the program name.

◆ GetOptions()

std::span< const CLIOption > rex::CLIArgList::GetOptions ( ) const

Returns the options in the order given. Each option has a name and a value if it has one.

◆ GetPositionals()

std::span< const std::string > rex::CLIArgList::GetPositionals ( ) const

Returns the arguments that are not options or option values.

◆ Has()

bool rex::CLIArgList::Has ( std::string_view name) const

Reports whether an option is present.

Parameters
nameOption name without the leading dashes.
Returns
True when –name or –name=value is present.

◆ Parse() [1/2]

CLIArgList rex::CLIArgList::Parse ( i32 argc,
char ** argv )
static

Parses the command line main receives.

Parameters
argcArgument count, including the program name.
argvArgument vector. argv[0] is the program name and is skipped.

◆ Parse() [2/2]

CLIArgList rex::CLIArgList::Parse ( std::span< const std::string > args)
static

Parses command line arguments held as strings.

Parameters
argsCommand line arguments without the program name.

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