libdnf5::cli::session

class AppendStringListOption : public libdnf5::cli::session::Option
#include <session.hpp>

AppendStringListOption is a wrapper around NamedArg and OptionStringList which allows specifying the argument multiple times and merging their values. E.g. &#8212;whatrequires=tree &#8212;whatrequires=plant -> option contains: “tree, plant”

Public Functions

explicit AppendStringListOption(libdnf5::cli::session::Command &command, const std::string &long_name, char short_name, const std::string &desc, const std::string &help)
explicit AppendStringListOption(libdnf5::cli::session::Command &command, const std::string &long_name, char short_name, const std::string &desc, const std::string &help, const std::string &allowed_values_regex, const bool icase, const std::string &delimiters = libdnf5::OptionStringList::get_default_delimiters())
~AppendStringListOption()
std::vector<std::string> get_value() const

Since

5.0

Returns:

Parsed value.

libdnf5::cli::ArgumentParser::NamedArg *get_arg()
class BoolOption : public libdnf5::cli::session::Option

Public Functions

explicit BoolOption(libdnf5::cli::session::Command &command, const std::string &long_name, char short_name, const std::string &desc, bool default_value, libdnf5::OptionBool *linked_option = nullptr)
~BoolOption()
bool get_value() const

Since

5.0

Returns:

Parsed value.

void set(libdnf5::Option::Priority priority, bool value)

Set bool value with priority for the option

Since

5.0

Parameters:
  • priority – Priority

  • value – Value

libdnf5::cli::ArgumentParser::NamedArg *get_arg()
class Command : public libdnf5::cli::ArgumentParserUserData

Public Functions

explicit Command(Session &session, const std::string &name)
virtual ~Command()
Command() = delete
Command(const Command &src) = delete
Command(Command &&src) = delete
Command &operator=(const Command &src) = delete
Command &operator=(Command &&src) = delete
virtual void set_parent_command()

Sets a parent command and group. Can add a new group to the parent command.

Since

5.0

virtual void set_argument_parser()

Set command arguments.

Since

5.0

virtual void register_subcommands()

Register subcommands.

Since

5.0

virtual void pre_configure()

Adjust configuration. Called after parsing the command line and but before loading configuration files.

Since

5.0

virtual void configure()

Adjust configuration. Called after parsing the command line and loading configuration files.

Since

5.0

virtual void load_additional_packages()

Loads additional packages that are not in the repositories.

Since

5.0

virtual void run()

Run the command.

Since

5.0

virtual void goal_resolved()

Called immediately after the goal is resolved.

Since

5.0

void throw_missing_command() const

Throw a ArgumentParserMissingCommandError exception with the command name in it.

Session &get_session() const noexcept

Since

5.0

Returns:

Pointer to the Session. The returned pointer must not be freed manually.

Command *get_parent_command() const noexcept

Since

5.0

Returns:

Pointer to the parent Command. Root command returns null because it has no parent. The returned pointer must not be freed manually.

libdnf5::cli::ArgumentParser::Command *get_argument_parser_command() const noexcept

Since

5.0

Returns:

Pointer to the underlying argument parser command. The returned pointer must not be freed manually.

class Option

Subclassed by libdnf5::cli::session::AppendStringListOption, libdnf5::cli::session::BoolOption, libdnf5::cli::session::StringArgumentList

Public Functions

Option(const Option &src) = delete
Option(Option &&src) = delete
~Option()
Option &operator=(const Option &src) = delete
Option &operator=(Option &&src) = delete
class Session

Public Functions

explicit Session()
~Session()
Session(const Session &src) = delete
Session(Session &&src)
Session &operator=(const Session &src) = delete
Session &operator=(Session &&src)
void add_and_initialize_command(std::unique_ptr<Command> &&command)

Store the command to the session and initialize it.

Since

5.0

Command *get_root_command()

Since

5.0

Returns:

Root command that represents the main program. The returned pointer must not be freed manually.

void set_root_command(Command &command)

Set command as the root command that represents the main program.

Since

5.0

Command *get_selected_command()

Since

5.0

Returns:

Selected (sub)command that a user specified on the command line. The returned pointer must not be freed manually.

void set_selected_command(Command *command)

Set command as the selected (sub)command that a user specified on the command line. We’re only pointing to a command that is owned by the Session already.

Since

5.0

libdnf5::cli::ArgumentParser &get_argument_parser()

Since

5.0

Returns:

The underlying argument parser.

void clear()

Remove all commands from the session and argument parser.

Since

5.0

class StringArgumentList : public libdnf5::cli::session::Option

Public Functions

explicit StringArgumentList(libdnf5::cli::session::Command &command, const std::string &name, const std::string &desc, int nargs)
explicit StringArgumentList(libdnf5::cli::session::Command &command, const std::string &name, const std::string &desc)
~StringArgumentList()
std::vector<std::string> get_value() const

Since

5.0

Returns:

Parsed value.

libdnf5::cli::ArgumentParser::PositionalArg *get_arg()