33namespace kaycxx::cli {
61 [[nodiscard]] std::string
const&
name() const noexcept;
68 [[nodiscard]] std::optional<std::
string> const&
description() const noexcept;
110 std::string_view
name,
111 std::string_view value_name,
112 std::optional<std::string_view>
description = std::nullopt
114 auto item = std::make_unique<cli::option<T>>(
name, value_name,
description);
115 auto& definition = *item;
116 add_switch(std::move(item));
134 template <parseable_value T>
136 std::string_view
name,
138 std::string_view value_name,
139 std::optional<std::string_view>
description = std::nullopt
142 auto& definition = *
item;
143 add_switch(std::move(
item));
160 template <parseable_value T>
162 std::string_view
name,
163 std::string_view value_name,
164 std::optional<std::string_view>
description = std::nullopt
167 item->mark_as_repeatable();
168 auto& definition = *
item;
169 add_switch(std::move(
item));
187 template <parseable_value T>
189 std::string_view
name,
191 std::string_view value_name,
192 std::optional<std::string_view>
description = std::nullopt
195 item->mark_as_repeatable();
196 auto& definition = *
item;
197 add_switch(std::move(
item));
211 template <parseable_value T>
213 ensure_parameter_allowed();
215 auto& definition = *
item;
216 parameters_.push_back(std::move(
item));
230 template <parseable_value T>
232 ensure_parameter_allowed();
234 auto& definition = *
item;
235 parameters_.push_back(std::move(
item));
319 void ensure_parameter_allowed()
const;
432 std::
string invocation_;
435 std::
optional<std::
string> description_;
452#include <kaycxx/cli/command_handle.hpp>
Defines access to parsed command line arguments.
Defines and parses a command-line application.
Definition app.hpp:50
Parsed command line arguments.
Definition args.hpp:41
Handle for a registered command.
Definition command_handle.hpp:25
Common base class for an application and its commands.
Definition command.hpp:45
command_handle add_command(std::string_view name, std::optional< std::string_view > description=std::nullopt)
Registers a child command.
cli::parameter_handle< T > parameter(std::string_view name, std::optional< std::string_view > description=std::nullopt)
Registers a single positional parameter.
Definition command.hpp:212
command(command const &)=delete
Prevents copying command definitions.
int print_version(std::ostream &out=std::cout) const
Writes generated version output.
int print_help(std::ostream &out=std::cout) const
Writes generated help output.
command(std::string_view name, std::optional< std::string_view > description, command *parent)
Creates a command definition.
cli::repeatable_option_handle< T > repeatable_option(std::string_view name, char alias, std::string_view value_name, std::optional< std::string_view > description=std::nullopt)
Registers a repeatable option with a short alias.
Definition command.hpp:188
cli::args parse(int argc, char *argv[]) const
Parses command line arguments.
std::string const & name() const noexcept
Returns the command name.
cli::option_handle< T > option(std::string_view name, char alias, std::string_view value_name, std::optional< std::string_view > description=std::nullopt)
Registers an option with a short alias.
Definition command.hpp:135
virtual ~command()=default
Destroys this command and all definitions owned by it.
cli::parameters_handle< T > parameters(std::string_view name, std::optional< std::string_view > description=std::nullopt)
Registers a positional parameter list.
Definition command.hpp:231
command & operator=(command const &)=delete
Prevents copy-assigning command definitions.
cli::repeatable_option_handle< T > repeatable_option(std::string_view name, std::string_view value_name, std::optional< std::string_view > description=std::nullopt)
Registers a repeatable option without a short alias.
Definition command.hpp:161
command(command &&other) noexcept
Moves a command definition.
std::optional< std::string > const & description() const noexcept
Returns this command's configured description.
Handle for a registered flag.
Definition flag_handle.hpp:22
Command line flag definition.
Definition flag.hpp:22
Handle for a registered option.
Definition option_handle.hpp:25
Typed command line option definition.
Definition option.hpp:156
Common base class for positional parameter definitions.
Definition parameter_base.hpp:23
Common base class for command line switches.
Definition switch_base.hpp:22
Checks whether a type can be used as a command line value.
Definition parse_value.hpp:63
Defines command line flags.
Defines the flag handle type.
Defines command line options.
Defines the option handle type.
Defines single positional parameters.
Defines the common base class for positional parameters.
Defines the positional parameter handle type.
Defines positional parameter lists.
Defines the positional parameter list handle type.
Defines the repeatable option handle type.
Defines the common base class for flags and options.