14#if CLI11_VERSION_MAJOR < 2 || (CLI11_VERSION_MAJOR == 2 && CLI11_VERSION_MINOR < 7) || \
15 (CLI11_VERSION_MAJOR == 2 && CLI11_VERSION_MINOR == 7 && CLI11_VERSION_PATCH < 2)
16#error "Uni20 requires CLI11 2.7.2 or newer"
62[[nodiscard]] parse_result
parse(CLI::App& app,
int argc,
char const*
const* argv, parse_policy policy = {});
65[[nodiscard]] std::vector<presentation::help_group>
help_groups(CLI::App
const& app);
75 parse_result
const& result);
79template <
typename T,
typename Converter>
80CLI::Option* converted_option(CLI::App& app, std::string names, T& target, std::string description, Converter converter)
82 auto* option = app.add_option_function<std::string>(
84 [&target, converter, names](std::string
const& token) {
87 target = converter(token);
89 catch (std::invalid_argument
const&
error)
91 throw CLI::ValidationError(names,
error.what());
93 catch (std::out_of_range
const&
error)
95 throw CLI::ValidationError(names,
error.what());
97 catch (std::runtime_error
const&
error)
99 throw CLI::ValidationError(names,
error.what());
102 std::move(description));
103 return option->run_callback_for_default();
110template <std::
unsigned_
integral T>
111 requires(!std::same_as<T, bool>)
115 detail::converted_option(app, std::move(names),
value, std::move(description), [](std::string
const&
text) {
117 auto const result = std::from_chars(
text.data(),
text.data() +
text.size(), parsed);
118 if (result.ec != std::errc{} || result.ptr !=
text.data() +
text.size())
119 throw std::invalid_argument(
"expected a representable nonnegative decimal integer: " +
text);
122 return option->type_name(
"COUNT")->default_function([&
value] {
return fmt::format(
"{}",
value); });
128template <std::
signed_
integral T>
130 std::string description = {})
132 auto* option = detail::converted_option(app, std::move(names),
value, std::move(description),
Signed value type that stores multiples of one half exactly.
Definition half_int.hpp:34
static auto parse(std::string_view text) -> basic_half_int
Parse a textual half-integer representation.
Definition half_int.hpp:172
Builder for simple terminal reports with headings, status lines, fields, and tables.
Definition presentation.hpp:602
locale_t value
Definition data_table.cpp:49
presentation::styled_text text
Definition display.cpp:141
Defines basic_half_int<T>, a signed integer type with half-integer resolution.
std::vector< presentation::help_group > help_groups(CLI::App const &app)
Project CLI11 option metadata into parser-independent semantic help groups.
Definition cli.cpp:150
CLI::Option * add_half_int_option(CLI::App &app, std::string names, basic_half_int< T > &value, std::string description={})
Bind an exact half-integer, accepting integer, .0/.5 decimal and denominator-two fractional forms.
Definition cli.hpp:129
presentation::report_builder help_report(CLI::App const &app, presentation::program_info const &program)
Build full help from the same options used for parsing, plus application-supplied content.
Definition cli.cpp:157
void configure(CLI::App &app, presentation::program_info const &program)
Register common help/version/build-info actions on a single-command application.
Definition cli.cpp:102
presentation::report_builder result_report(CLI::App const &app, presentation::program_info const &program, parse_result const &result)
Build the selected informational/error document; a run outcome has no document and is rejected.
Definition cli.cpp:190
parse_result parse(CLI::App &app, int argc, char const *const *argv, parse_policy policy)
Parse argc/argv, preserving CLI11's argument boundaries and help precedence.
Definition cli.cpp:116
presentation::report_builder build_info_report(presentation::program_info const &program)
Build application and existing Uni20 build information without running numerical initialization.
Definition cli.cpp:166
no_arguments
Whether an empty invocation displays help or parses application defaults.
Definition cli.hpp:32
CLI::Option * add_count_option(CLI::App &app, std::string names, T &value, std::string description={})
Bind an unsigned decimal count with complete-token, negative and overflow checks.
Definition cli.hpp:112
action
The executable decides whether to calculate or render an informational/error result.
Definition cli.hpp:23
stream
Selects the ordinary display stream for a message.
Definition display.hpp:25
auto to_string(basic_half_int< T > value) -> std::string
Format a half-integer as an integer or decimal .5.
Definition half_int.hpp:477
Parser-independent application identity and help documents.
Executable policy for empty invocations and usage failures.
Definition cli.hpp:39
int empty_exit_code
Definition cli.hpp:42
display::stream empty_destination
Definition cli.hpp:41
int error_exit_code
Definition cli.hpp:43
no_arguments empty
Definition cli.hpp:40
Owned parse outcome; parsing itself does not print, open files or terminate the process.
Definition cli.hpp:48
int exit_code
Definition cli.hpp:51
std::string message
Definition cli.hpp:52
action requested
Definition cli.hpp:49
display::stream destination
Definition cli.hpp:50
Application identity and explanatory content, independent of any option parser.
Definition program.hpp:32