libdnf5::cli

enum class libdnf5::cli::ExitCode : int

Values:

enumerator SUCCESS
enumerator ERROR
enumerator ARGPARSER_ERROR
class AbortedByUserError : public libdnf5::cli::Error
#include <exception.hpp>

Exception is thrown when the user does not confirm the transaction.

Public Functions

AbortedByUserError()
inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParser

Public Functions

ArgumentParser(const ArgumentParser&) = delete
ArgumentParser(ArgumentParser&&) = delete
ArgumentParser &operator=(const ArgumentParser&) = delete
ArgumentParser &operator=(ArgumentParser&&) = delete
ArgumentParser()
~ArgumentParser()
CommandOrdinary *add_new_command(const std::string &id)

Constructs a new command and stores it to the argument parser. Returns a pointer to the newly created command.

CommandAlias *add_new_command_alias(const std::string &id, Command &attached_command)

Constructs a new command alias and stores it to the argument parser. Returns a pointer to the newly created command alias.

NamedArg *add_new_named_arg(const std::string &id)

Constructs a new named argument and stores it to the argument parser. Returns a pointer to the newly created named argument.

PositionalArg *add_new_positional_arg(const std::string &id, std::vector<std::unique_ptr<libdnf5::Option>> *values)

Constructs a new positional argument and stores it to the argument parser. Returns a pointer to the newly created positional argument.

PositionalArg *add_new_positional_arg(const std::string &id, int nargs, libdnf5::Option *init_value, std::vector<std::unique_ptr<libdnf5::Option>> *values)

Constructs a new positional argument and stores it to the argument parser. Returns a pointer to the newly created positional argument.

Group *add_new_group(const std::string &id)

Constructs a new group and stores it to the argument parser. Returns a pointer to the newly created group.

std::vector<Argument*> *add_conflict_args_group(std::unique_ptr<std::vector<Argument*>> &&conflict_args_group)

Moves a list of conflicting argument to the parser. Returns a pointer to the list.

libdnf5::Option *add_init_value(std::unique_ptr<libdnf5::Option> &&src)

Moves the option with the initial value to the argument parser. Returns a pointer to the option.

std::vector<std::unique_ptr<libdnf5::Option>> *add_new_values()

Constructs a new empty list of values and stores it to the argument parser. Returns a pointer to the newly created list.

std::vector<std::unique_ptr<libdnf5::Option>> *add_values(std::unique_ptr<std::vector<std::unique_ptr<libdnf5::Option>>> &&values)

Moves an existing list of values to the argument parser. Returns a pointer to the list.

void set_root_command(Command *command) noexcept

Sets the “root” command. This is the top-level command in the command hierarchy. It can contain named and positional arguments and subcommands.

Command *get_root_command() noexcept

Gets the “root” command. This is the top-level command in the command hierarchy. It can contain named and positional arguments and subcommands.

Command *get_selected_command() noexcept

Get the selected command. Needed for printing help, bash completion etc.

void parse(int argc, const char *const argv[])

Parses input. The parser from the “root” command is called. The “AssertionError” exception is thrown when the “root” command is not set.

void reset_parse_count()

Reset parse count in all arguments.

void set_inherit_named_args(bool enable) noexcept

Enables/disables the inheritance of named arguments for the parser. If the parser does not find a named argument definition during subcommand processing and named arguments inheritance is enabled, parser searches the named arguments of the parent commands.

Parameters:

enable – true - enable parent argument inheritance, false - disable

bool get_inherit_named_args() const noexcept

Returns true if the inheritance of named arguments is enabled for the parser.

Command &get_command(const std::string &id_path)

Returns (sub)command with given ID path. The root command ID must be omitted. It is added automatically.

Parameters:

id_path – command ID path, e.g. “module.list”; “” - returns root_command

Throws:
  • AssertionError – if root command is not set

  • ArgumentParser::Command::CommandNotFound – if command is not found.

NamedArg &get_named_arg(const std::string &id_path, bool search_in_parent)

Returns named argument with given full ID path. The root command ID must be omitted. It is added automatically. If the named argument is not found in the path and search in the parent command is enabled, it will be searched in the parent command. E.g. “installroot” is global option -> instead of “repoquery.installroot” returns “installroot”.

Parameters:
  • id_path – named argument ID path, e.g. “installroot”, “repoquery.installed”

  • search_in_parent – true - enable search in parent command, false - disable

Throws:
PositionalArg &get_positional_arg(const std::string &id_path, bool search_in_parent)

Returns positional argument with given full ID path. The root command ID must be omitted. It is added automatically. If the positional argument is not found in the path and search in the parent command is enabled, it will be searched in the parent command. E.g. “installroot” is global option -> instead of “repoquery.installroot” returns “installroot”.

Parameters:
  • id_path – positional argument ID path, e.g. “repoquery.keys”

  • search_in_parent – true - enable search in parent command, false - disable

Throws:
const std::vector<std::unique_ptr<Command>> &get_commands() const noexcept

Gets a list of all commands stored in the argument parser.

const std::vector<std::unique_ptr<NamedArg>> &get_named_args() const noexcept

Gets a list of all named arguments stored in the argument parser.

const std::vector<std::unique_ptr<PositionalArg>> &get_positional_args() const noexcept

Gets a list of all positional argument stored in the argument parser.

void complete(int argc, const char *const argv[], int complete_arg_idx)

Prints the completed argument from the complete_arg_idx position in the argv array. In case of more than one potential completion matches, prints a table with the potential matches along with their short help descriptions.

void set_complete_add_description(bool enable) noexcept

Sets whether the description is added to the suggested arguments on completion.

bool get_complete_add_description() noexcept

Returns whether the description is added to the suggested arguments on completion.

class Argument

Subclassed by libdnf5::cli::ArgumentParser::Command, libdnf5::cli::ArgumentParser::NamedArg, libdnf5::cli::ArgumentParser::PositionalArg

Public Functions

Argument() = delete
Argument(const Argument&) = delete
Argument(Argument&&) = delete
Argument &operator=(const Argument&) = delete
Argument &operator=(Argument&&) = delete
virtual ~Argument()
void set_long_description(std::string descr) noexcept

Sets a long description of the argument.

void set_description(std::string descr) noexcept

Sets a brief description of the argument.

void set_conflict_arguments(std::vector<Argument*> *args) noexcept

Passes a list of arguments that cannot be used with this argument. Can contain this argument. Groups of conflicting argument can be used.

void add_conflict_argument(Argument &conflict_arg)

Adds a conflicting argument. Also adds reverse conflict.

void add_conflict_arguments_from_another(Argument &src_arg)

Add conflict arguments from another argument. Also adds reverse conflicts.

const std::string &get_id() const noexcept

Gets argument id.

const std::string &get_long_description() const

Gets a long description of the argument.

const std::string &get_description() const

Gets a brief description of the argument.

std::vector<Argument*> *get_conflict_arguments() noexcept

Returns a list of arguments that cannot be used with this argument or nullptr.

int get_parse_count() const noexcept

Gets the number of times the argument was used during analysis. Can be used to determine how many times the argument has been used on the command line.

void reset_parse_count() noexcept

Set the number of times the argument was used during analysis count to 0.

Argument *get_conflict_argument() const noexcept

Tests input for arguments that cannot be used with this argument. Returns the first conflicting argument or nullptr.

void set_complete(bool complete) noexcept

Sets whether the argument participates in completion.

bool get_complete() const noexcept

Returns whether the argument participates in completion.

virtual void help() const noexcept
ArgumentParser &get_argument_parser() const noexcept
void set_user_data(ArgumentParserUserData *user_data) noexcept

Sets a pointer to user data in the argument.

ArgumentParserUserData *get_user_data() const noexcept

Gets a pointer to the user data attached to the argument.

class Command : public libdnf5::cli::ArgumentParser::Argument

Subclassed by libdnf5::cli::ArgumentParser::CommandAlias, libdnf5::cli::ArgumentParser::CommandOrdinary

Public Types

using ParseHookFunc = std::function<bool(Command *arg, const char *cmd, int argc, const char *const argv[])>

Public Functions

Command() = delete
Command(const Command&) = delete
Command(Command&&) = delete
Command &operator=(const Command&) = delete
Command &operator=(Command&&) = delete
~Command() override
virtual void register_command(Command *cmd) = 0

Registers (sub)command to the command. An exception is thrown when a command with the same ID is already registered.

virtual void register_named_arg(NamedArg *arg) = 0

Registers named argument to the command. An exception is thrown when a named argument with the same ID is already registered.

virtual void register_positional_arg(PositionalArg *arg) = 0

Registers positional argument to the command. An exception is thrown when a positional argument with the same ID is already registered.

virtual void register_group(Group *grp) = 0
virtual const std::vector<Command*> &get_commands() const noexcept = 0

Gets a list of registered commands.

virtual const std::vector<NamedArg*> &get_named_args() const noexcept = 0

Gets a list of registered named arguments.

virtual const std::vector<PositionalArg*> &get_positional_args() const noexcept = 0

Gets a list of registered positional arguments.

virtual const std::vector<Group*> &get_groups() const noexcept = 0

Gets a list of registered groups.

virtual Command &get_command(const std::string &id) const = 0

Returns (sub)command with given ID. Exception CommandNotFound is thrown if command is not found.

virtual NamedArg &get_named_arg(const std::string &id) const = 0

Returns named argument with given ID. Exception NamedArgNotFound is thrown if argument is not found.

virtual PositionalArg &get_positional_arg(const std::string &id) const = 0

Returns positional argument with given ID. Exception PositionalArgNotFound is thrown if argument is not found.

virtual Group &get_group(const std::string &id) const = 0

Returns registered group with given ID. Exception ArgumentParserNotFoundError is thrown if group is not found.

virtual void set_parse_hook_func(ParseHookFunc &&func) = 0

Sets the user function for parsing the argument.

virtual const ParseHookFunc &get_parse_hook_func() const noexcept = 0

Gets the user function for parsing the argument.

virtual void parse(const char *option, int argc, const char *const argv[]) = 0

Parses input. The input may contain named arguments, (sub)commands and positional arguments.

virtual void help() const noexcept override

Prints command help text.

void set_commands_help_header(std::string text) noexcept

Sets the header of the subcommand table. Used to generate help.

void set_named_args_help_header(std::string text) noexcept

Sets the header of the named arguments table. Used to generate help.

void set_positional_args_help_header(std::string text) noexcept

Sets the header of the positional arguments table. Used to generate help.

const std::string &get_commands_help_header() const noexcept

Gets the header of the subcommand table. Used to generate help.

const std::string &get_named_args_help_header() const noexcept

Gets the header of the named arguments table. Used to generate help.

const std::string &get_positional_args_help_header() const noexcept

Gets the header of the positional arguments table. Used to generate help.

Command *get_parent() const noexcept

Returns the pointer to the parent Command (as set by register_command()).

virtual std::vector<std::string> get_invocation() const noexcept

Gets the list of command-line arguments needed to invoke the command. Command aliases are resolved; so get_invocation for a RepoListCommand would return {"dnf5", "repo", "list"}

class CommandAlias : public libdnf5::cli::ArgumentParser::Command

Public Functions

CommandAlias() = delete
CommandAlias(const CommandAlias&) = delete
CommandAlias(CommandAlias&&) = delete
CommandAlias &operator=(const CommandAlias&) = delete
CommandAlias &operator=(CommandAlias&&) = delete
~CommandAlias() override
virtual void register_command(Command *cmd) override

Registers (sub)command to the command. An exception is thrown when a command with the same ID is already registered.

virtual void register_named_arg(NamedArg *arg) override

Registers named argument to the command. An exception is thrown when a named argument with the same ID is already registered.

virtual void register_positional_arg(PositionalArg *arg) override

Registers positional argument to the command. An exception is thrown when a positional argument with the same ID is already registered.

virtual void register_group(Group *grp) override
virtual std::vector<std::string> get_invocation() const noexcept override

Gets the list of command-line arguments needed to invoke the command. Command aliases are resolved; so get_invocation for a RepoListCommand would return {"dnf5", "repo", "list"}

virtual const std::vector<Command*> &get_commands() const noexcept override

Gets a list of registered commands.

virtual const std::vector<NamedArg*> &get_named_args() const noexcept override

Gets a list of registered named arguments.

virtual const std::vector<PositionalArg*> &get_positional_args() const noexcept override

Gets a list of registered positional arguments.

virtual const std::vector<Group*> &get_groups() const noexcept override

Gets a list of registered groups.

virtual Command &get_command(const std::string &id) const override

Returns (sub)command with given ID. Exception CommandNotFound is thrown if command is not found.

virtual NamedArg &get_named_arg(const std::string &id) const override

Returns named argument with given ID. Exception NamedArgNotFound is thrown if argument is not found.

virtual PositionalArg &get_positional_arg(const std::string &id) const override

Returns positional argument with given ID. Exception PositionalArgNotFound is thrown if argument is not found.

virtual Group &get_group(const std::string &id) const override

Returns registered group with given ID. Exception ArgumentParserNotFoundError is thrown if group is not found.

virtual void set_parse_hook_func(ParseHookFunc &&func) override

Sets the user function for parsing the argument.

virtual const ParseHookFunc &get_parse_hook_func() const noexcept override

Gets the user function for parsing the argument.

virtual void parse(const char *option, int argc, const char *const argv[]) override

Parses input. The input may contain named arguments, (sub)commands and positional arguments.

Command &get_attached_command() noexcept

Returns the Command to which the CommandAlias is attached.

void attach_named_arg(const std::string &id_path, const std::string &value)
class CommandOrdinary : public libdnf5::cli::ArgumentParser::Command

Public Functions

CommandOrdinary() = delete
CommandOrdinary(const CommandOrdinary&) = delete
CommandOrdinary(CommandOrdinary&&) = delete
CommandOrdinary &operator=(const CommandOrdinary&) = delete
CommandOrdinary &operator=(CommandOrdinary&&) = delete
~CommandOrdinary() override
virtual void register_command(Command *cmd) override

Registers (sub)command to the command. An exception is thrown when a command with the same ID is already registered.

virtual void register_named_arg(NamedArg *arg) override

Registers named argument to the command. An exception is thrown when a named argument with the same ID is already registered.

virtual void register_positional_arg(PositionalArg *arg) override

Registers positional argument to the command. An exception is thrown when a positional argument with the same ID is already registered.

virtual void register_group(Group *grp) override
virtual const std::vector<Command*> &get_commands() const noexcept override

Gets a list of registered commands.

virtual const std::vector<NamedArg*> &get_named_args() const noexcept override

Gets a list of registered named arguments.

virtual const std::vector<PositionalArg*> &get_positional_args() const noexcept override

Gets a list of registered positional arguments.

virtual const std::vector<Group*> &get_groups() const noexcept override

Gets a list of registered groups.

virtual Command &get_command(const std::string &id) const override

Returns (sub)command with given ID. Exception CommandNotFound is thrown if command is not found.

virtual NamedArg &get_named_arg(const std::string &id) const override

Returns named argument with given ID. Exception NamedArgNotFound is thrown if argument is not found.

virtual PositionalArg &get_positional_arg(const std::string &id) const override

Returns positional argument with given ID. Exception PositionalArgNotFound is thrown if argument is not found.

virtual Group &get_group(const std::string &id) const override

Returns registered group with given ID. Exception ArgumentParserNotFoundError is thrown if group is not found.

virtual void set_parse_hook_func(ParseHookFunc &&func) override

Sets the user function for parsing the argument.

virtual const ParseHookFunc &get_parse_hook_func() const noexcept override

Gets the user function for parsing the argument.

virtual void parse(const char *option, int argc, const char *const argv[]) override

Parses input. The input may contain named arguments, (sub)commands and positional arguments.

class Group

Public Functions

Group() = delete
Group(const Group&) = delete
Group(Group&&) = delete
Group &operator=(const Group&) = delete
Group &operator=(Group&&) = delete
~Group()
void set_header(std::string header) noexcept

Sets group header.

const std::string &get_id() const noexcept

Gets group id.

const std::string &get_header() const noexcept

Gets group header.

void register_argument(Argument *arg)

Registers an argument to the group. An exception is thrown when an argument with the same ID is already registered.

const std::vector<Argument*> &get_arguments() const noexcept

Gets a list of registered arguments.

class NamedArg : public libdnf5::cli::ArgumentParser::Argument

Public Types

using ParseHookFunc = std::function<bool(NamedArg *arg, const char *option, const char *value)>

Public Functions

NamedArg() = delete
NamedArg(const NamedArg&) = delete
NamedArg(NamedArg&&) = delete
NamedArg &operator=(const NamedArg&) = delete
NamedArg &operator=(NamedArg&&) = delete
~NamedArg() override
void set_long_name(std::string long_name) noexcept

Sets long name of argument. Long name is prefixed with two dashes on the command line (e.g. “–help”).

void set_short_name(char short_name)

Sets short name of argument. Short name is prefixed with one dash on the command line (e.g. “-h”).

void set_has_value(bool has_value)

Does the argument need a value on the command line?

Links the value to the argument. Parsed value is stored there if if get_store_value() == true.

void set_const_value(std::string const_value) noexcept

Sets constant argument value. It is used for argument without value on command line (get_has_value() == false).

const std::string &get_long_name() const noexcept

Gets long name of argument. Long name is prefixed with two dashes on the command line (e.g. “–help”).

char get_short_name() const noexcept

Gets short name of argument. Short name is prefixed with one dash on the command line (e.g. “-h”).

bool get_has_value() const noexcept

Returns true if the argument need a value on the command line.

const std::string &get_const_value() const noexcept

Gets constant argument value. It is used for argument without value on command line (get_has_value() == false).

libdnf5::Option *get_linked_value() noexcept

Gets the value. Parsed value is stored there if if get_store_value() == true.

const libdnf5::Option *get_linked_value() const noexcept

Gets value. Parsed value is stored there if if get_store_value() == true.

void set_store_value(bool enable) noexcept

Enables/disables storing parsed values. Values can be processed / stored in the user parse hook function.

bool get_store_value() const noexcept

Returns true if storing the parsed values is enabled.

void set_parse_hook_func(ParseHookFunc &&func)

Sets the user function for parsing the argument.

const ParseHookFunc &get_parse_hook_func() const noexcept

Gets the user function for parsing the argument.

void set_arg_value_help(std::string text)

Sets help text for argument value.

const std::string &get_arg_value_help() const noexcept

Gets help text for argument value.

libdnf5::cli::ArgumentParser::NamedArg *add_alias(const std::string &id, const std::string &long_name, char short_name, libdnf5::cli::ArgumentParser::Group *group)

Create alias for this named arg. The alias is not shown in completion. The conflicting args of the alias are copied to match the current conflicting args of this named arg.

void attach_named_arg(const std::string &id_path, const std::string &value)
class PositionalArg : public libdnf5::cli::ArgumentParser::Argument

Public Types

using ParseHookFunc = std::function<bool(PositionalArg *arg, int argc, const char *const argv[])>
using CompleteHookFunc = std::function<std::vector<std::string>(const char *arg_to_complete)>

Public Functions

PositionalArg() = delete
PositionalArg(const PositionalArg&) = delete
PositionalArg(PositionalArg&&) = delete
PositionalArg &operator=(const PositionalArg&) = delete
PositionalArg &operator=(PositionalArg&&) = delete
~PositionalArg() override
int get_nvals() const noexcept

Gets the number of values required by this argument on the command line. May return special values: OPTIONAL, UNLIMITED, AT_LEAST_ONE

void set_store_value(bool enable)

Enables/disables storing parsed values. Values can be processed / stored in the user parse hook function. The “AssertionError” exception is thrown when “true” is requested but the storage array “values” is not set.

bool get_store_value() const noexcept

Returns true if storing the parsed values is enabled.

std::vector<std::unique_ptr<libdnf5::Option>> *get_linked_values() noexcept

Gets list of values. Parsed values are stored there if if get_store_value() == true.

void set_parse_hook_func(ParseHookFunc &&func)

Sets the user function for parsing the argument.

const ParseHookFunc &get_parse_hook_func() const noexcept

Gets the user function for parsing the argument.

void set_complete_hook_func(CompleteHookFunc &&func)

Sets the user function to complete the argument.

const CompleteHookFunc &get_complete_hook_func() const noexcept

Gets the user function to complete the argument.

void set_nrepeats(int nrepeats)

Sets the required number of repetitions of this argument on the command line. The special values OPTIONAL, UNLIMITED, AT_LEAST_ONE can be used.

int get_nrepeats() const noexcept

Gets the required number of repetitions of this argument on the command line. May return special values: OPTIONAL, UNLIMITED, AT_LEAST_ONE

Public Static Attributes

static constexpr int OPTIONAL = {0}
static constexpr int UNLIMITED = {-1}
static constexpr int AT_LEAST_ONE = {-2}
class ArgumentParserArgumentInvalidIdError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when the Argument id contains not allowed ‘.’ character.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserConflictingArgumentsError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when conflicting arguments are used together.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserError : public libdnf5::cli::Error
#include <argument_parser_errors.hpp>

Parent for all ArgumentsParser runtime errors.

Subclassed by libdnf5::cli::ArgumentParserArgumentInvalidIdError, libdnf5::cli::ArgumentParserConflictingArgumentsError, libdnf5::cli::ArgumentParserGroupArgumentIdRegisteredError, libdnf5::cli::ArgumentParserIdAlreadyRegisteredError, libdnf5::cli::ArgumentParserInvalidValueError, libdnf5::cli::ArgumentParserMissingCommandError, libdnf5::cli::ArgumentParserMissingDependentArgumentError, libdnf5::cli::ArgumentParserMissingPositionalArgumentError, libdnf5::cli::ArgumentParserNamedArgMissingValueError, libdnf5::cli::ArgumentParserNamedArgValueNotExpectedError, libdnf5::cli::ArgumentParserNotFoundError, libdnf5::cli::ArgumentParserPositionalArgFewValuesError, libdnf5::cli::ArgumentParserPositionalArgumentFormatError, libdnf5::cli::ArgumentParserUnknownArgumentError

class ArgumentParserGroupArgumentIdRegisteredError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when an argument with the same ID is already registered.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserIdAlreadyRegisteredError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when the command, named argument, positional argument, or group with the same ID is already registered.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserInvalidValueError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when the given argument value is not valid.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserMissingCommandError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when no command is found.

class ArgumentParserMissingDependentArgumentError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when the command, named argument, positiona argument, or group needs an additional argument.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserMissingPositionalArgumentError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when a command requires a positional argument that was not found.

class ArgumentParserNamedArgMissingValueError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown if the named argument requires a value and the value is missing.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserNamedArgValueNotExpectedError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown if the named argument is defined without a value and a value is present.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserNotFoundError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when the command, named_argument, or positional argument was not found.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserPositionalArgFewValuesError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when there are too few values for the positional argument.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ArgumentParserPositionalArgumentFormatError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is thrown when a positional argument has invalid format.

class ArgumentParserUnknownArgumentError : public libdnf5::cli::ArgumentParserError
#include <argument_parser_errors.hpp>

Exception is generated in the case of an unexpected argument.

Public Functions

template<typename ...Ss>
inline ArgumentParserUnknownArgumentError(const std::string command, const std::string argument, const BgettextMessage &format, Ss&&... args)
inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

inline const std::string &get_command() const
inline const std::string &get_argument() const
class ArgumentParserUserData
#include <argument_parser.hpp>

Base class for user data used in ArgumentParser::Argument.

Subclassed by libdnf5::cli::session::Command

class CommandExitError : public libdnf5::cli::Error
#include <exception.hpp>

Exception used when non-standard exit code should be returned.

Public Functions

template<typename ...Ss>
inline explicit CommandExitError(int exit_code, BgettextMessage format, Ss&&... args)

Constructs the error with given exit code and with custom formatted error message.

Parameters:
  • exit_code – The exit code

  • format – The format string for the message

  • args – The format arguments

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

inline int get_exit_code() const noexcept
Returns:

The exit code

class Error : public libdnf5::Error
#include <exception.hpp>

Base class for libdnf5-cli exceptions.

Subclassed by libdnf5::cli::AbortedByUserError, libdnf5::cli::ArgumentParserError, libdnf5::cli::CommandExitError, libdnf5::cli::GoalResolveError, libdnf5::cli::InsufficientPrivilegesError, libdnf5::cli::ReadOnlySystemError, libdnf5::cli::SilentCommandExitError

Public Functions

inline virtual const char *get_domain_name() const noexcept override
Returns:

The domain name (namespace and enclosing class names) of the exception.

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class GoalResolveError : public libdnf5::cli::Error
#include <exception.hpp>

Exception is thrown when libdnf5 fails to resolve the transaction.

Public Functions

explicit GoalResolveError(const std::vector<std::string> resolve_logs)

Construct Error from a list of string representations of resolve logs.

Parameters:

resolve_logs – List of resolve logs

inline explicit GoalResolveError(const libdnf5::base::Transaction &transaction)

A constructor that extracts errors from the transaction.

Parameters:

transaction – The failed transaction

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

const char *what() const noexcept override
class InsufficientPrivilegesError : public libdnf5::cli::Error
#include <exception.hpp>

Exception is thrown when the user does not have enough privileges to perform requested operation.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class ReadOnlySystemError : public libdnf5::cli::Error
#include <exception.hpp>

Exception is thrown when trying to write to a read-only system.

Public Functions

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

class SilentCommandExitError : public libdnf5::cli::Error
#include <exception.hpp>

Exception used when non-standard exit code should be returned without displaying any message to the user.

Public Functions

explicit SilentCommandExitError(int exit_code)

Constructs the error with given exit code.

Parameters:

exit_code – The exit code

inline virtual const char *get_name() const noexcept override
Returns:

The exception class name.

inline int get_exit_code() const noexcept
Returns:

The exit code