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,
378 fp.parse_option_value(container_value, in)
379 } -> std::same_as<option_parse_result>;
383 typename container_option_t::value_type tmp{};
388 value.push_back(tmp);
405 template <arithmetic option_t>
411 if (res.ec == std::errc::result_out_of_range)
413 else if (res.ec == std::errc::invalid_argument || res.ptr != &in[in.
size()])
435 else if (in ==
"true")
437 else if (in ==
"false")
452 template <
typename option_type>
457 std::string msg{
"Value parse failed for " + option_name +
": "};
461 throw user_input_error{msg +
"Argument " + input_value +
" could not be parsed as type "
469 throw user_input_error{msg +
"Numeric argument " + input_value +
" is not in the valid range ["
495 template <
typename option_type,
typename id_type>
505 if ((*option_it).size() > id_size)
507 if ((*option_it)[id_size] ==
'=')
509 if ((*option_it).size() == id_size + 1)
511 input_value = (*option_it).
substr(id_size + 1);
515 input_value = (*option_it).
substr(id_size);
526 input_value = *option_it;
531 throw_on_input_error<option_type>(res,
prepend_dash(
id), input_value);
555 template <
typename option_type,
typename id_type>
565 +
" is no list/container but declared multiple times.");
581 template <detail::is_container_option option_type,
typename id_type>
587 if (seen_at_least_once)
596 return seen_at_least_once;
617 if (!arg.empty() && arg[0] ==
'-')
623 else if (arg[1] !=
'-' && arg.size() > 2)
626 +
". In case this is meant to be a non-option/argument/parameter, "
627 +
"please specify the start of arguments with '--'. "
628 +
"See -h/--help for program information.");
633 +
". In case this is meant to be a non-option/argument/parameter, "
634 +
"please specify the start of non-options with '--'. "
635 +
"See -h/--help for program information.");
661 throw too_many_arguments(
"Too many arguments provided. Please see -h/--help for more information.");
684 template <
typename option_type,
typename val
idator_type>
695 if (short_id_is_set && long_id_is_set && !detail::is_container_option<option_type>)
697 +
" is no list/container but specified multiple times");
699 if (short_id_is_set || long_id_is_set)
716 +
" is required but not set.");
754 template <
typename option_type,
typename val
idator_type>
766 throw too_few_arguments(
"Not enough positional arguments provided (Need at least "
768 +
"). See -h/--help for more information.");
770 if constexpr (detail::is_container_option<
781 throw_on_input_error<option_type>(res,
id, *it);
797 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:102
Argument parser exception thrown when a required option is missing.
Definition exceptions.hpp:89
Argument parser exception thrown when too few arguments are provided.
Definition exceptions.hpp:76
Argument parser exception thrown when too many arguments are provided.
Definition exceptions.hpp:63
Argument parser exception thrown when encountering unknown option.
Definition exceptions.hpp:50
Argument parser exception thrown when an argument could not be casted to the according type.
Definition exceptions.hpp:128
option_spec
Used to further specify argument_parser options/flags.
Definition auxiliary.hpp:245
@ required
Definition auxiliary.hpp:247
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.