Skip to content

Commit

Permalink
StringListOption: Add delimiters with default value
Browse files Browse the repository at this point in the history
`StringListOption` is a wrapper for `OptionStringList` both need to
support custom delimiters.
  • Loading branch information
kontura committed Nov 16, 2022
1 parent 486b628 commit f94d86e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions include/libdnf-cli/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ class StringListOption : public Option {
const std::string & long_name,
char short_name,
const std::string & desc,
const std::string & help);
const std::string & help,
const char * delimiters = OptionStringList::DEFAULT_DELIMITERS);

explicit StringListOption(
libdnf::cli::session::Command & command,
Expand All @@ -199,7 +200,8 @@ class StringListOption : public Option {
const std::string & desc,
const std::string & help,
const std::string & allowed_values_regex,
const bool icase);
const bool icase,
const char * delimiters = OptionStringList::DEFAULT_DELIMITERS);

/// @return Parsed value.
/// @since 5.0
Expand Down
12 changes: 7 additions & 5 deletions libdnf-cli/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ StringListOption::StringListOption(
const std::string & desc,
const std::string & help,
const std::string & allowed_values_regex,
const bool icase) {
const bool icase,
const char * delimiters) {
auto & parser = command.get_session().get_argument_parser();
conf = dynamic_cast<libdnf::OptionStringList *>(parser.add_init_value(
std::make_unique<libdnf::OptionStringList>(std::vector<std::string>(), allowed_values_regex, icase)));
conf = dynamic_cast<libdnf::OptionStringList *>(parser.add_init_value(std::make_unique<libdnf::OptionStringList>(
std::vector<std::string>(), allowed_values_regex, icase, delimiters)));
arg = parser.add_new_named_arg(long_name);

if (!long_name.empty()) {
Expand Down Expand Up @@ -165,8 +166,9 @@ StringListOption::StringListOption(
const std::string & long_name,
char short_name,
const std::string & desc,
const std::string & help)
: StringListOption(command, long_name, short_name, desc, help, "", false) {}
const std::string & help,
const char * delimiters)
: StringListOption(command, long_name, short_name, desc, help, "", false, delimiters) {}


StringArgumentList::StringArgumentList(
Expand Down

0 comments on commit f94d86e

Please sign in to comment.