cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::ArgParameter< T > Struct Template Reference

Parameter bag used when constructing ArgImpl or PositionalImpl with named fields. More...

#include <argument.hh>

Public Attributes

std::string_view help {}
 Help text shown in --help output.
Presence presence {Presence::optional}
 Whether the argument is required.
std::optional< T > default_value {}
 Default value when the argument is absent.
std::function< void(const T &)> on_parse {}
 Callback invoked once after parsing completes.
std::string_view env {}
 Environment variable name to fall back to when the option is absent from the command line.
bool hidden {}
 Whether this argument is omitted from generated help.
std::string_view deprecated {}
 Optional deprecation message shown in generated help.

Detailed Description

template<class T>
struct cli::ArgParameter< T >

Parameter bag used when constructing ArgImpl or PositionalImpl with named fields.

Allows brace-initialisation with named members, e.g.:

cli::Option<int, "count"> count{cli::ArgParameter<int>{
.help = "Number of repetitions",
.presence = cli::required,
.default_value = 1,
}};
constexpr auto required
Convenience constant for Presence::required.
Arg< Name, ShortName, detail::ActionFor< T >::set_once > Option
A single-value option that stores the parsed result in T.
Definition argument.hh:594
Parameter bag used when constructing ArgImpl or PositionalImpl with named fields.
Definition argument.hh:66
Template Parameters
TThe storage value type of the argument.

Definition at line 66 of file argument.hh.

Member Data Documentation

◆ default_value

template<class T>
std::optional<T> cli::ArgParameter< T >::default_value {}

Default value when the argument is absent.

Definition at line 70 of file argument.hh.

◆ deprecated

template<class T>
std::string_view cli::ArgParameter< T >::deprecated {}

Optional deprecation message shown in generated help.

Definition at line 77 of file argument.hh.

◆ env

template<class T>
std::string_view cli::ArgParameter< T >::env {}

Environment variable name to fall back to when the option is absent from the command line.

Definition at line 73 of file argument.hh.

◆ help

template<class T>
std::string_view cli::ArgParameter< T >::help {}

Help text shown in --help output.

Definition at line 67 of file argument.hh.

◆ hidden

template<class T>
bool cli::ArgParameter< T >::hidden {}

Whether this argument is omitted from generated help.

Definition at line 75 of file argument.hh.

◆ on_parse

template<class T>
std::function<void(const T&)> cli::ArgParameter< T >::on_parse {}

Callback invoked once after parsing completes.

Definition at line 72 of file argument.hh.

◆ presence

template<class T>
Presence cli::ArgParameter< T >::presence {Presence::optional}

Whether the argument is required.

Definition at line 68 of file argument.hh.


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