73 template <
typename option_type,
typename val
idator_type>
79 validator_type && option_validator)
82 [
this, &value, short_id, long_id, spec, option_validator]()
84 get_option(value, short_id, long_id, spec, option_validator);
98 [
this, &value, short_id, long_id]()
107 template <
typename option_type,
typename val
idator_type>
110 validator_type && option_validator)
113 [
this, &value, option_validator]()
156 template <
typename id_type>
159 if constexpr (std::same_as<std::remove_cvref_t<id_type>,
std::string>)
162 return is_char<'\0'>(
id);
186 template <
typename iterator_type,
typename id_type>
187 static iterator_type
find_option_id(iterator_type begin_it, iterator_type end_it, id_type
const &
id)
198 if constexpr (std::same_as<id_type, char>)
202 return current_arg.
substr(0, full_id.
size()) == full_id;
207 return current_arg.
substr(0, full_id.
size()) == full_id &&
208 (current_arg.
size() == full_id.
size()
209 || current_arg[full_id.
size()] ==
'=');
229 return {
"--" + long_id};
238 return {
'-', short_id};
248 if (short_id ==
'\0')
250 else if (long_id.
empty())
277 if (arg[0] ==
'-' && arg.size() > 1 && arg[1] !=
'-')
279 auto pos = arg.find(short_id);
281 if (pos != std::string::npos)
302 template <
typename option_t>
309 if (stream.fail() || !stream.eof())
322 template <named_enumeration option_t>
325 auto map = seqan3::enumeration_names<option_t>;
327 if (
auto it = map.find(in); it == map.end())
331 [](
auto pair1,
auto pair2)
333 if constexpr (std::totally_ordered<option_t>)
335 if (pair1.second != pair2.second)
336 return pair1.second < pair2.second;
338 return pair1.first < pair2.first;
343 ". Please use one of: ",
344 key_value_pairs | std::views::keys)};
373 template <detail::is_container_option container_option_t,
typename format_parse_t = format_parse>
374 requires requires (format_parse_t fp,
375 typename container_option_t::value_type & container_value,
377 { fp.parse_option_value(container_value, in) } -> std::same_as<option_parse_result>;
381 typename container_option_t::value_type tmp{};
386 value.push_back(tmp);
403 template <arithmetic option_t>
409 if (res.ec == std::errc::result_out_of_range)
411 else if (res.ec == std::errc::invalid_argument || res.ptr != &in[in.
size()])
433 else if (in ==
"true")
435 else if (in ==
"false")
450 template <
typename option_type>
455 std::string msg{
"Value parse failed for " + option_name +
": "};
459 throw user_input_error{msg +
"Argument " + input_value +
" could not be parsed as type "
467 throw user_input_error{msg +
"Numeric argument " + input_value +
" is not in the valid range ["
493 template <
typename option_type,
typename id_type>
503 if ((*option_it).size() > id_size)
505 if ((*option_it)[id_size] ==
'=')
507 if ((*option_it).size() == id_size + 1)
509 input_value = (*option_it).
substr(id_size + 1);
513 input_value = (*option_it).
substr(id_size);
524 input_value = *option_it;
529 throw_on_input_error<option_type>(res,
prepend_dash(
id), input_value);
553 template <
typename option_type,
typename id_type>
563 +
" is no list/container but declared multiple times.");
579 template <detail::is_container_option option_type,
typename id_type>
585 if (seen_at_least_once)
594 return seen_at_least_once;
615 if (!arg.empty() && arg[0] ==
'-')
621 else if (arg[1] !=
'-' && arg.size() > 2)
624 +
". In case this is meant to be a non-option/argument/parameter, "
625 +
"please specify the start of arguments with '--'. "
626 +
"See -h/--help for program information.");
631 +
". In case this is meant to be a non-option/argument/parameter, "
632 +
"please specify the start of non-options with '--'. "
633 +
"See -h/--help for program information.");
659 throw too_many_arguments(
"Too many arguments provided. Please see -h/--help for more information.");
682 template <
typename option_type,
typename val
idator_type>
693 if (short_id_is_set && long_id_is_set && !detail::is_container_option<option_type>)
695 +
" is no list/container but specified multiple times");
697 if (short_id_is_set || long_id_is_set)
714 +
" is required but not set.");
752 template <
typename option_type,
typename val
idator_type>
764 throw too_few_arguments(
"Not enough positional arguments provided (Need at least "
766 +
"). See -h/--help for more information.");
768 if constexpr (detail::is_container_option<
779 throw_on_input_error<option_type>(res,
id, *it);
795 throw_on_input_error<option_type>(res,
id, *it);
The <charconv> header from C++17's standard library.
Argument parser exception thrown when a non-list option is declared multiple times.
Definition exceptions.hpp:104
Argument parser exception thrown when a required option is missing.
Definition exceptions.hpp:91
Argument parser exception thrown when too few arguments are provided.
Definition exceptions.hpp:78
Argument parser exception thrown when too many arguments are provided.
Definition exceptions.hpp:65
Argument parser exception thrown when encountering unknown option.
Definition exceptions.hpp:52
Argument parser exception thrown when an argument could not be casted to the according type.
Definition exceptions.hpp:130
option_spec
Used to further specify argument_parser options/flags.
Definition auxiliary.hpp:249
@ required
Definition auxiliary.hpp:251
A type that satisfies std::is_arithmetic_v<t>.
The concept for option validators passed to add_option/positional_option.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
std::string to_string(value_type &&... values)
Streams all parameters via the seqan3::debug_stream and returns a concatenated string.
Definition to_string.hpp:26
SeqAn specific customisations in the standard namespace.
Provides character predicates for tokenisation.