20#if __has_include(<seqan3/version.hpp>)
21# include <seqan3/version.hpp>
24namespace sharg::detail
39 template <
typename value_type,
bool verbose = true>
45 return verbose ?
"signed 8 bit integer" :
"int8";
47 return verbose ?
"unsigned 8 bit integer" :
"uint8";
49 return verbose ?
"signed 16 bit integer" :
"int16";
51 return verbose ?
"unsigned 16 bit integer" :
"uint16";
53 return verbose ?
"signed 32 bit integer" :
"int32";
55 return verbose ?
"unsigned 32 bit integer" :
"uint32";
57 return verbose ?
"signed 64 bit integer" :
"int64";
59 return verbose ?
"unsigned 64 bit integer" :
"uint64";
61 return verbose ?
"double" :
"double";
63 return verbose ?
"float" :
"float";
65 return verbose ?
"bool" :
"bool";
67 return verbose ?
"char" :
"char";
69 return verbose ?
"std::string" :
"string";
71 return verbose ?
"std::filesystem::path" :
"path";
75 return sharg::detail::type_name_as_string<value_type>;
83 template <detail::is_container_option container_type,
bool verbose = true>
86 return get_type_name_as_string<std::ranges::range_value_t<container_type>, verbose>();
93 template <
typename option_value_type>
96 return (
"(\\fI" + get_type_name_as_string<option_value_type>() +
"\\fP)");
104 template <detail::is_container_option container_type>
107 return (
"(\\fIList\\fP of \\fI" + get_type_name_as_string<container_type>() +
"\\fP)");
124 if (!
id.empty_short_id())
125 term =
"\\fB-" +
std::string(1,
id.short_id) +
"\\fP";
127 if (
id.has_both_ids())
130 if (!
id.empty_long_id())
131 term.
append(
"\\fB--" +
id.long_id +
"\\fP");
147 for (
auto c : original)
175 auto it{flag_cluster.
begin()};
177 if (flag_cluster[0] ==
'-')
180 for (; it != flag_cluster.
end() - 1; ++it)
181 tmp.
append({
'-', *it,
',',
' '});
184 tmp.
append({
'a',
'n',
'd',
' ',
'-', flag_cluster[flag_cluster.
size() - 1]});
201 template <
typename option_type,
typename default_type>
207 message <<
" Default: ";
214 auto view = std::views::transform(value,
234 static constexpr bool needs_string_quote = option_is_string || (option_is_path && value_is_string);
236 if constexpr (needs_string_quote)
242 return message.str();
293 return std::tolower(c);
307 return std::toupper(c);
317template <
typename derived_type>
338 bool const advanced) :
349 template <
typename option_type,
typename val
idator_t>
361 if (
auto const & validator_message =
config.
validator.get_help_page_message(); !validator_message.empty())
362 info +=
". " + validator_message;
373 get_type_name_as_string<option_type, false>(),
381 template <
typename val
idator_t>
388 derived_t().print_list_item(id, description);
400 template <
typename option_type,
typename val
idator_t>
404 auto positional_default_message = [&value]() ->
std::string
419 if (
auto const & validator_message =
config.
validator.get_help_page_message(); !validator_message.empty())
420 return ". " + validator_message;
428 default_message = positional_default_message(),
429 validator_message = positional_validator_message(),
437 description + default_message + validator_message);
468 derived_t().print_section(
"Description");
475 derived_t().print_section(
"Subcommands");
476 derived_t().print_line(
"This program must be invoked with one of the following subcommands:",
false);
478 derived_t().print_line(
"- \\fB" + name +
"\\fP",
false);
479 derived_t().print_line(
"See the respective help page for further details (e.g. by calling " +
meta.
app_name
482 derived_t().print_line(
"The following options belong to the top-level parser and need to be "
483 "specified \\fBbefore\\fP the subcommand key word. Every argument after the "
484 "subcommand key word is passed on to the corresponding sub-parser.",
490 derived_t().print_section(
"Positional Arguments");
504 derived_t().print_subsection(
"Common options");
505 derived_t().print_list_item(
"\\fB-h\\fP, \\fB--help\\fP",
"Prints the help page.");
506 derived_t().print_list_item(
"\\fB-hh\\fP, \\fB--advanced-help\\fP",
507 "Prints the help page including advanced options.");
508 derived_t().print_list_item(
"\\fB--version\\fP",
"Prints the version information.");
509 derived_t().print_list_item(
"\\fB--copyright\\fP",
"Prints the copyright/license information.");
510 derived_t().print_list_item(
"\\fB--export-help\\fP (std::string)",
511 "Export the help page information. Value must be one of "
512 + detail::supported_exports +
".");
514 derived_t().print_list_item(
"\\fB--version-check\\fP (bool)",
515 "Whether to check for the newest app version. Default: true");
565 [
this, text, is_paragraph]()
567 derived_t().print_line(text, is_paragraph);
650#ifdef SEQAN3_VERSION_CSTRING
651 std::string const seqan3_version_str{seqan3::seqan3_version_cstring};
652 derived_t().print_line(
derived_t().in_bold(
"SeqAn version: ") + seqan3_version_str,
false);
688 +
"2006-2026 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.",
693 derived_t().print_line(
derived_t().in_bold(
"In your academic works please cite: "),
false);
708 derived_t().print_line(
"For full copyright and/or warranty information see "
709 +
derived_t().in_bold(
"--copyright") +
".",
724#ifdef __cpp_lib_ranges_join_with
725 auto view = std::views::join_with(executable_name,
' ');
729 for (
size_t i = 0; i < executable_name.
size(); ++i)
732 synopsis_line +=
' ';
733 synopsis_line += executable_name[i];
745 synopsis_line +=
" " + it->option_str;
749 synopsis_line +=
" [\\fB--\\fP]";
752 synopsis_line +=
" " + it->option_str;
818 opt_str +=
" \\fI" + type_str +
"\\fP";
822 opt_str =
"[" + opt_str +
"]";
829 opt_str = opt_str +
" [" + opt_str +
"]...";
870 template <
typename val
idator_t>
Provides auxiliary information.
Whether the option type is considered to be a container.
Definition detail/concept.hpp:38
Provides sharg::config class.
Provides the concept sharg::detail::is_container_option.
T emplace_back(T... args)
T find_first_of(T... args)
T find_last_of(T... args)
std::string to_string(value_types &&... values)
Streams all parameters via std::ostringstream and returns a concatenated string.
Definition to_string.hpp:40
update_notifications
Indicates whether application allows automatic update notifications by the sharg::parser.
Definition auxiliary.hpp:27
@ on
Automatic update notifications should be enabled.
Provides sharg::detail::id_pair.
Option struct that is passed to the sharg::parser::add_option() function.
Definition config.hpp:43
std::string description
The description to be shown on any (exported) help page.
Definition config.hpp:68
std::string long_id
The long identifier for the option (e.g. "age", making the option callable via --age).
Definition config.hpp:62
bool hidden
Whether the option should be hidden.
Definition config.hpp:117
bool advanced
Whether the option should only be displayed on the advanced help page.
Definition config.hpp:105
bool required
Whether the option is required.
Definition config.hpp:129
validator_t validator
A sharg::validator that verifies the value after parsing (callable).
Definition config.hpp:135
char short_id
The short identifier for the option (e.g. 'a', making the option callable via -a).
Definition config.hpp:53
std::string default_message
The default message to be shown on any (exported) help page.
Definition config.hpp:87
A simple struct to store a short and a long identifier for an option.
Definition id_pair.hpp:25
Provides traits to inspect some information of a type, for example its name.
Provides some standard validators for (positional) options.
constexpr char const * sharg_version_cstring
The full version as null terminated string.
Definition version.hpp:64