Class Options

Class Documentation

class Options

Options container and parsing methods.

Owns the various data objects.

Public Functions

Options(std::optional<UserInfo::SharedPtrConst> user_info, std::optional<EmailRecipients::SharedPtrConst> recipients, const bool curl_verbose, const bool intraprocess, const std::optional<std::chrono::nanoseconds> polling_period)

Constructor.

The user info, recipients, and polling period values are optional if intraprocess is enabled. The curl verbose option is meaningless if intraprocess is enabled.

Not to be called directly: use parse_options_from_*() instead.

Parameters:
  • user_info – the user info, or std::nullopt if intraprocess

  • recipients – the recipients, or std::nullopt if intraprocess

  • curl_verbose – the curl verbose status

  • intraprocess – the intraprocess status

  • polling_period – the polling period

~Options()
std::optional<UserInfo::SharedPtrConst> get_user_info() const

Get user information data.

Returns:

the UserInfo object, or std::nullopt

std::optional<EmailRecipients::SharedPtrConst> get_recipients() const

Get email recipient data.

Returns:

the EmailRecipients object, or std::nullopt

bool curl_verbose() const

Get the curl verbose status.

Returns:

true if verbose, false otherwise

bool intraprocess() const

Get the intraprocess status.

Returns:

true if intraprocess, false otherwise

std::optional<std::chrono::nanoseconds> polling_period() const

Get the polling period value.

Returns:

the polling period

Public Static Functions

static std::optional<std::shared_ptr<Options>> parse_options_from_args(int argc, char const *const argv[])

Parse options from CLI arguments.

Parameters:
  • argc – the argument count

  • argv – the argument vector

Returns:

the resulting Options object, or std::nullopt if it failed

static std::optional<std::shared_ptr<Options>> parse_options_from_file()

Parse options from config file.

It first tries to read $EMAIL_CONFIG_FILE, or $PWD/email.yml if it is not set. If that does not work, it then tries to read from a backup file path: ~/email.yml.

Returns:

the resulting Options object, or std::nullopt if it failed

static std::optional<std::shared_ptr<Options>> yaml_to_options(YAML::Node)

Get Options object from yaml node.

Returns:

the resulting Options object, or std::nullopt if it failed

static std::optional<std::shared_ptr<Options>> parse_options_file(const rcpputils::fs::path &file_path)

Parse options file.

Parameters:

file_path – the path to the file to parse

Returns:

the resulting Options object, or std::nullopt if it failed