30namespace seqan3::detail
44 template <
typename value_type>
45 static std::string get_type_name_as_string(value_type
const & )
48 using types = type_list<int8_t,
63 "unsigned 8 bit integer",
64 "signed 16 bit integer",
65 "unsigned 16 bit integer",
66 "signed 32 bit integer",
67 "unsigned 32 bit integer",
68 "signed 64 bit integer",
69 "unsigned 64 bit integer",
75 "std::filesystem::path"};
77 if constexpr (list_traits::contains<type, types>)
78 return names[list_traits::find<type, types>];
80 return detail::type_name_as_string<value_type>;
87 template <sequence_container container_type>
89 requires (!std::is_same_v<container_type, std::string>)
91 static std::string get_type_name_as_string(container_type
const & )
93 typename container_type::value_type tmp{};
94 return get_type_name_as_string(tmp);
102 template <
typename option_value_type>
103 static std::string option_type_and_list_info(option_value_type
const & value)
105 return (
"(\\fI" + get_type_name_as_string(value) +
"\\fP)");
114 template <
typename container_type>
120 return (
"(\\fIList\\fP of \\fI" + get_type_name_as_string(
container) +
"\\fP)");
134 if (short_id !=
'\0')
135 term =
"\\fB-" +
std::string(1, short_id) +
"\\fP";
137 if (short_id !=
'\0' && !long_id.
empty())
140 if (!long_id.
empty())
141 term.
append(
"\\fB--" + long_id +
"\\fP");
157 for (
auto c : original)
185 auto it{flag_cluster.
begin()};
187 if (flag_cluster[0] ==
'-')
190 for (; it != flag_cluster.
end() - 1; ++it)
205template <
typename derived_type>
206class format_help_base :
public format_base
212 format_help_base() =
default;
213 format_help_base(format_help_base
const & pf) =
default;
214 format_help_base & operator=(format_help_base
const & pf) =
default;
215 format_help_base(format_help_base &&) =
default;
216 format_help_base & operator=(format_help_base &&) =
default;
217 ~format_help_base() =
default;
224 command_names{names}, show_advanced_options{
advanced}
232 template <
typename option_type,
typename val
idator_type>
233 void add_option(option_type & value,
238 validator_type && option_validator)
240 std::string id = prep_id_for_help(short_id, long_id) +
" " + option_type_and_list_info(value);
243 info += option_validator.get_help_page_message();
244 store_help_page_element([
this,
id, info] () { derived_t().print_list_item(
id, info); }, spec);
250 void add_flag(
bool & SEQAN3_DOXYGEN_ONLY(value),
256 std::string id = prep_id_for_help(short_id, long_id);
257 store_help_page_element([
this,
id, desc] () { derived_t().print_list_item(
id, desc); }, spec);
263 template <
typename option_type,
typename val
idator_type>
264 void add_positional_option(option_type & value,
266 validator_type & option_validator)
268 std::string msg = option_validator.get_help_page_message();
270 positional_option_calls.
push_back([
this, &value, desc, msg] ()
272 ++positional_option_count;
273 derived_t().print_list_item(detail::to_string(
"\\fBARGUMENT-", positional_option_count,
"\\fP ",
274 option_type_and_list_info(value)),
278 ? detail::to_string(
" Default: ", value,
". ")
287 void parse(argument_parser_meta_data & parser_meta)
291 derived_t().print_header();
293 if (!meta.synopsis.empty())
295 derived_t().print_section(
"Synopsis");
296 derived_t().print_synopsis();
299 if (!meta.description.empty())
301 derived_t().print_section(
"Description");
302 for (
auto desc : meta.description)
306 if (!command_names.empty())
308 derived_t().print_section(
"Subcommands");
309 derived_t().print_line(
"This program must be invoked with one of the following subcommands:",
false);
311 derived_t().print_line(
"- \\fB" + name +
"\\fP",
false);
312 derived_t().print_line(
"See the respective help page for further details (e.g. by calling " +
313 meta.app_name +
" " + command_names[0] +
" -h).",
true);
314 derived_t().print_line(
"The following options below belong to the top-level parser and need to be "
315 "specified \\fBbefore\\fP the subcommand key word. Every argument after the "
316 "subcommand key word is passed on to the corresponding sub-parser.",
true);
320 if (!positional_option_calls.empty())
321 derived_t().print_section(
"Positional Arguments");
324 for (
auto f : positional_option_calls)
328 if (!parser_set_up_calls.empty())
329 derived_t().print_section(
"Options");
332 for (
auto f : parser_set_up_calls)
335 if (!meta.examples.empty())
337 derived_t().print_section(
"Examples");
338 for (
auto example : meta.examples)
346 derived_t().print_footer();
356 store_help_page_element([
this, title] () { derived_t().print_section(title); }, spec);
364 store_help_page_element([
this, title] () { derived_t().print_subsection(title); }, spec);
372 store_help_page_element([
this, text, is_paragraph] () { derived_t().print_line(text, is_paragraph); }, spec);
380 store_help_page_element([
this, key, desc] () { derived_t().print_list_item(key, desc); }, spec);
397 argument_parser_meta_data meta;
404 derived_type & derived_t()
406 return static_cast<derived_type &
>(*this);
410 void print_synopsis()
412 for (
unsigned i = 0; i < meta.synopsis.size(); ++i)
415 text.
append(meta.synopsis[i]);
418 derived_t().print_line(text,
false);
427 derived_t().print_line(text,
true);
436 derived_t().print_section(
"Version");
437 derived_t().print_line(derived_t().in_bold(
"Last update: ") + meta.date,
false);
438 derived_t().print_line(derived_t().in_bold(meta.app_name +
" version: ") + meta.version,
false);
439 derived_t().print_line(derived_t().in_bold(
"SeqAn version: ") + version_str,
false);
441 if (!
empty(meta.url))
443 derived_t().print_section(
"Url");
444 derived_t().print_line(meta.url,
false);
452 if ((!
empty(meta.short_copyright)) ||
453 (!
empty(meta.long_copyright)) ||
454 (!
empty(meta.citation)) ||
455 (!
empty(meta.author)) ||
456 (!
empty(meta.email)))
458 derived_t().print_section(
"Legal");
460 if (!
empty(meta.short_copyright))
462 derived_t().print_line(derived_t().in_bold(meta.app_name +
" Copyright: ") + meta.short_copyright,
466 if (!
empty(meta.author))
468 derived_t().print_line(derived_t().in_bold(
"Author: ") + meta.author,
false);
471 if (!
empty(meta.email))
473 derived_t().print_line(derived_t().in_bold(
"Contact: ") + meta.email,
false);
476 derived_t().print_line(derived_t().in_bold(
"SeqAn Copyright: ") +
477 "2006-2021 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.",
false);
479 if (!
empty(meta.citation))
481 derived_t().print_line(derived_t().in_bold(
"In your academic works please cite: ") + meta.citation,
485 if (!
empty(meta.long_copyright))
487 derived_t().print_line(
"For full copyright and/or warranty information see " +
488 derived_t().in_bold(
"--copyright") +
".",
499 unsigned positional_option_count{0};
503 bool show_advanced_options{
true};
519 parser_set_up_calls.
push_back(std::move(printer));
Provides auxiliary information.
Provides parser related exceptions.
The <filesystem> header from C++17's standard library.
T find_first_of(T... args)
T find_last_of(T... args)
option_spec
Used to further specify argument_parser options/flags.
Definition: auxiliary.hpp:249
@ advanced
Definition: auxiliary.hpp:256
@ hidden
Definition: auxiliary.hpp:260
@ required
Definition: auxiliary.hpp:251
The (most general) container concept as defined by the standard library.
A more refined container concept than seqan3::container.
constexpr char const * seqan3_version_cstring
The full version as null terminated string.
Definition: version.hpp:73
Provides traits for seqan3::type_list.
Provides traits to inspect some information of a type, for example its name.
Adaptations of concepts from the standard library.
Provides some standard validators for (positional) options.
Provides SeqAn version macros and global variables.