33namespace kaycxx::cli {
40 std::optional<std::string_view>
version = std::nullopt;
46 std::optional<std::string_view>
author = std::nullopt;
49 std::optional<std::string_view>
email = std::nullopt;
52 std::optional<std::string_view>
bugs = std::nullopt;
55 std::optional<std::string_view>
copyright = std::nullopt;
58 std::optional<std::string_view>
license = std::nullopt;
105 [[nodiscard]] std::string
const&
name() const noexcept;
112 [[nodiscard]] std::optional<std::
string> const&
version() const noexcept;
119 [[nodiscard]] std::optional<std::
string> const&
author() const noexcept;
126 [[nodiscard]] std::optional<std::
string> const&
email() const noexcept;
133 [[nodiscard]] std::optional<std::
string> const&
bugs() const noexcept;
140 [[nodiscard]] std::optional<std::
string> const&
copyright() const noexcept;
147 [[nodiscard]] std::optional<std::
string> const&
license() const noexcept;
154 [[nodiscard]] std::optional<std::
string> const&
description() const noexcept;
196 std::string_view
name,
197 std::string_view value_name,
198 std::optional<std::string_view>
description = std::nullopt
200 auto item = std::make_unique<cli::option<T>>(
name, value_name,
description);
201 auto& definition = *item;
202 add_switch(std::move(item));
220 template <parseable_value T>
222 std::string_view
name,
224 std::string_view value_name,
225 std::optional<std::string_view>
description = std::nullopt
228 auto& definition = *
item;
229 add_switch(std::move(
item));
246 template <parseable_value T>
248 std::string_view
name,
249 std::string_view value_name,
250 std::optional<std::string_view>
description = std::nullopt
253 item->mark_as_repeatable();
254 auto& definition = *
item;
255 add_switch(std::move(
item));
273 template <parseable_value T>
275 std::string_view
name,
277 std::string_view value_name,
278 std::optional<std::string_view>
description = std::nullopt
281 item->mark_as_repeatable();
282 auto& definition = *
item;
283 add_switch(std::move(
item));
297 template <parseable_value T>
300 auto& definition = *
item;
301 parameters_.push_back(std::move(
item));
315 template <parseable_value T>
318 auto& definition = *
item;
319 parameters_.push_back(std::move(
item));
378 void add_switch(std::unique_ptr<switch_base>
item);
437 std::
optional<std::
string> version_;
449 std::
optional<std::
string> copyright_;
452 std::
optional<std::
string> license_;
455 std::
optional<std::
string> description_;
Defines access to parsed command line arguments.
Parsed command line arguments.
Definition args.hpp:38
Defines and parses a command line interface.
Definition command.hpp:68
int print_version() const
Writes generated version output to standard output.
command(std::string_view name, command_options options=command_options())
Creates a command definition.
std::optional< std::string > const & copyright() const noexcept
Returns the configured copyright notice.
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:298
std::optional< std::string > const & license() const noexcept
Returns the configured license text.
command(command const &)=delete
Prevents copying command definitions.
command & operator=(command &&other) noexcept=default
Move-assigns a command definition.
std::optional< std::string > const & author() const noexcept
Returns the configured author name.
int print_version(std::ostream &out) const
Writes generated version output.
int print_help(std::ostream &out) const
Writes generated help output.
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:274
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:221
int print_help() const
Writes generated help output to standard output.
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:316
command & operator=(command const &)=delete
Prevents copy-assigning command definitions.
command(command &&other) noexcept=default
Moves a command definition.
std::optional< std::string > const & bugs() const noexcept
Returns the email address or URL to which to report bugs to.
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:247
std::optional< std::string > const & version() const noexcept
Returns the configured command version.
std::optional< std::string > const & description() const noexcept
Returns the configured command description.
std::optional< std::string > const & email() const noexcept
Returns the configured author email address.
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:93
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.
Optional metadata for a command.
Definition command.hpp:38
std::optional< std::string_view > bugs
Email address or website URL to which to report bugs to.
Definition command.hpp:52
std::optional< std::string_view > version
Command version string used by version output.
Definition command.hpp:40
std::optional< std::string_view > email
Author contact address used by generated version output.
Definition command.hpp:49
std::optional< std::string_view > author
Author name used by generated version output.
Definition command.hpp:46
std::optional< std::string_view > license
License text used by generated version output.
Definition command.hpp:58
std::optional< std::string_view > copyright
Copyright notice used by generated version output.
Definition command.hpp:55
std::optional< std::string_view > description
Short command description used by generated help output.
Definition command.hpp:43
Defines the common base class for flags and options.