Sharg 1.2.2-rc.1
The argument parser for bio-c++ tools.
Loading...
Searching...
No Matches
format_base.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2026, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2026, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
11#pragma once
12
13#include <sharg/auxiliary.hpp>
14#include <sharg/config.hpp>
18#include <sharg/validators.hpp>
19
20#if __has_include(<seqan3/version.hpp>)
21# include <seqan3/version.hpp>
22#endif
23
24namespace sharg::detail
25{
26
32{
33protected:
39 template <typename value_type, bool verbose = true>
41 {
42 using type = std::decay_t<value_type>;
43
44 if constexpr (std::is_same_v<type, int8_t>)
45 return verbose ? "signed 8 bit integer" : "int8";
46 else if constexpr (std::is_same_v<type, uint8_t>)
47 return verbose ? "unsigned 8 bit integer" : "uint8";
48 else if constexpr (std::is_same_v<type, int16_t>)
49 return verbose ? "signed 16 bit integer" : "int16";
50 else if constexpr (std::is_same_v<type, uint16_t>)
51 return verbose ? "unsigned 16 bit integer" : "uint16";
52 else if constexpr (std::is_same_v<type, int32_t>)
53 return verbose ? "signed 32 bit integer" : "int32";
54 else if constexpr (std::is_same_v<type, uint32_t>)
55 return verbose ? "unsigned 32 bit integer" : "uint32";
56 else if constexpr (std::is_same_v<type, int64_t>)
57 return verbose ? "signed 64 bit integer" : "int64";
58 else if constexpr (std::is_same_v<type, uint64_t>)
59 return verbose ? "unsigned 64 bit integer" : "uint64";
60 else if constexpr (std::is_same_v<type, double>)
61 return verbose ? "double" : "double";
62 else if constexpr (std::is_same_v<type, float>)
63 return verbose ? "float" : "float";
64 else if constexpr (std::is_same_v<type, bool>)
65 return verbose ? "bool" : "bool";
66 else if constexpr (std::is_same_v<type, char>)
67 return verbose ? "char" : "char";
68 else if constexpr (std::is_same_v<type, std::string>)
69 return verbose ? "std::string" : "string";
71 return verbose ? "std::filesystem::path" : "path";
72 else if constexpr (!verbose && std::is_enum_v<type>)
73 return "enum";
74 else
75 return sharg::detail::type_name_as_string<value_type>;
76 }
77
83 template <detail::is_container_option container_type, bool verbose = true>
85 {
86 return get_type_name_as_string<std::ranges::range_value_t<container_type>, verbose>();
87 }
88
93 template <typename option_value_type>
94 static std::string option_type_and_list_info(option_value_type const &)
95 {
96 return ("(\\fI" + get_type_name_as_string<option_value_type>() + "\\fP)");
97 }
98
104 template <detail::is_container_option container_type>
105 static std::string option_type_and_list_info(container_type const &)
106 {
107 return ("(\\fIList\\fP of \\fI" + get_type_name_as_string<container_type>() + "\\fP)");
108 }
109
119 static std::string prep_id_for_help(detail::id_pair const & id, bool const is_synopsis = false)
120 {
121 // Build list item term.
122 std::string term;
123
124 if (!id.empty_short_id())
125 term = "\\fB-" + std::string(1, id.short_id) + "\\fP";
126
127 if (id.has_both_ids())
128 is_synopsis ? term.append("|") : term.append(", ");
129
130 if (!id.empty_long_id())
131 term.append("\\fB--" + id.long_id + "\\fP");
132
133 return term;
134 }
135
143 {
144 std::string escaped;
145 escaped.reserve(original.size()); // will be at least as long
146
147 for (auto c : original)
148 {
149 if (c == '"')
150 escaped.append("&quot;");
151 else if (c == '\'')
152 escaped.append("&apos;");
153 else if (c == '&')
154 escaped.append("&amp;");
155 else if (c == '<')
156 escaped.append("&lt;");
157 else if (c == '>')
158 escaped.append("&gt;");
159 else
160 escaped.push_back(c);
161 }
162
163 return escaped;
164 }
165
172 static std::string expand_multiple_flags(std::string const & flag_cluster)
173 {
174 std::string tmp;
175 auto it{flag_cluster.begin()};
176
177 if (flag_cluster[0] == '-')
178 ++it;
179
180 for (; it != flag_cluster.end() - 1; ++it)
181 tmp.append({'-', *it, ',', ' '});
182
183 tmp.erase(tmp.find_last_of(',')); // remove last ', '
184 tmp.append({'a', 'n', 'd', ' ', '-', flag_cluster[flag_cluster.size() - 1]});
185
186 return tmp;
187 }
188
201 template <typename option_type, typename default_type>
202 static std::string get_default_message(option_type const & SHARG_DOXYGEN_ONLY(option), default_type const & value)
203 {
205
206 std::stringstream message{};
207 message << " Default: ";
208
210 {
211 // If we have a list of strings, we want to quote each string.
213 {
214 auto view = std::views::transform(value,
215 [](auto const & val)
216 {
217 return std::quoted(val);
218 });
219 message << detail::to_string(view);
220 }
221 else // Otherwise we just print the list or the default_message without quotes.
222 {
223 message << detail::to_string(value);
224 }
225 }
226 else
227 {
228 static constexpr bool option_is_string = std::same_as<option_type, std::string>;
229 static constexpr bool option_is_path = std::same_as<option_type, std::filesystem::path>;
230 static constexpr bool value_is_string = std::same_as<default_type, std::string>;
231
232 // Quote: std::string (from value + default_message), and std::filesystem::path (default_message).
233 // std::filesystem::path is quoted by the STL's operator<< in detail::to_string.
234 static constexpr bool needs_string_quote = option_is_string || (option_is_path && value_is_string);
235
236 if constexpr (needs_string_quote)
237 message << std::quoted(value);
238 else
239 message << detail::to_string(value);
240 }
241
242 return message.str();
243 }
244
287 static void print_as_lowercase(std::string const & str)
288 {
291 [](unsigned char c)
292 {
293 return std::tolower(c);
294 });
295 }
296
301 static void print_as_uppercase(std::string const & str)
302 {
305 [](unsigned char c)
306 {
307 return std::toupper(c);
308 });
309 }
310};
311
317template <typename derived_type>
319{
320private:
324 format_help_base() = default;
325 format_help_base(format_help_base const & pf) = default;
329 ~format_help_base() = default;
330
337 update_notifications const version_updates,
338 bool const advanced) :
339 version_check_dev_decision{version_updates},
340 command_names{names},
341 show_advanced_options{advanced}
342 {}
344
345public:
349 template <typename option_type, typename validator_t>
350 void add_option(option_type & value, config<validator_t> const & config)
351 {
355
357 info += ((config.required) ? std::string{} : get_default_message(value, value));
358 else
360
361 if (auto const & validator_message = config.validator.get_help_page_message(); !validator_message.empty())
362 info += ". " + validator_message;
363
365 [this, id, info]()
366 {
367 derived_t().print_list_item(id, info);
368 },
369 config);
370
373 get_type_name_as_string<option_type, false>(),
376 }
377
381 template <typename validator_t>
382 void add_flag(bool & SHARG_DOXYGEN_ONLY(value), config<validator_t> const & config)
383 {
386 [this, id = prep_id_for_help(id_pair), description = config.description]()
387 {
388 derived_t().print_list_item(id, description);
389 },
390 config);
391
392 // Store for synopsis generation
395 }
396
400 template <typename option_type, typename validator_t>
401 void add_positional_option(option_type & value, config<validator_t> const & config)
402 {
403 // a list at the end may be empty and thus have a default value
404 auto positional_default_message = [&value]() -> std::string
405 {
407 {
408 return get_default_message(value, value);
409 }
410 else
411 {
412 (void)value; // Silence unused variable warning.
413 return {};
414 }
415 };
416
417 auto positional_validator_message = [&config]() -> std::string
418 {
419 if (auto const & validator_message = config.validator.get_help_page_message(); !validator_message.empty())
420 return ". " + validator_message;
421 else
422 return {};
423 };
424
426 [this,
427 &value,
428 default_message = positional_default_message(),
429 validator_message = positional_validator_message(),
430 description = config.description]()
431 {
433 derived_t().print_list_item(detail::to_string("\\fBARGUMENT-",
435 "\\fP ",
437 description + default_message + validator_message);
438 });
439
440 // Store for synopsis generation
441 store_synopsis_positional(get_type_name_as_string<option_type, false>(),
443 }
444
450 void parse(parser_meta_data & parser_meta, std::vector<std::string> const & executable_name)
451 {
452 meta = parser_meta;
453
454 derived_t().print_header();
455
456 if (meta.synopsis.empty())
457 generate_default_synopsis(executable_name);
458
459 // Synopsis can be disabled by setting `parser.info.synopsis = {""};`
460 if (!meta.synopsis.empty() && !meta.synopsis.front().empty())
461 {
462 derived_t().print_section("Synopsis");
463 derived_t().print_synopsis();
464 }
465
466 if (!meta.description.empty())
467 {
468 derived_t().print_section("Description");
469 for (auto && desc : meta.description)
470 print_line(desc);
471 }
472
473 if (!command_names.empty())
474 {
475 derived_t().print_section("Subcommands");
476 derived_t().print_line("This program must be invoked with one of the following subcommands:", false);
477 for (std::string const & name : command_names)
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
480 + " " + command_names[0] + " -h).",
481 true);
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.",
485 true);
486 }
487
488 // add positional options if specified
490 derived_t().print_section("Positional Arguments");
491
492 // each call will evaluate the function derived_t().print_list_item()
493 for (auto && f : positional_option_calls)
494 f();
495
496 // There are always options because of the common options
497 derived_t().print_section("Options");
498
499 // each call will evaluate the function derived_t().print_list_item()
500 for (auto && f : parser_set_up_calls)
501 f();
502
503 // print Common options after developer options
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");
516
517 if (!meta.examples.empty())
518 {
519 derived_t().print_section("Examples");
520 for (auto && example : meta.examples)
521 print_line(example);
522 }
523
525
526 print_legal();
527
528 derived_t().print_footer();
529 }
530
534 void add_section(std::string const & title, bool const advanced_only)
535 {
537 [this, title]()
538 {
539 derived_t().print_section(title);
540 },
541 advanced_only,
542 false /* never hidden */);
543 }
544
548 void add_subsection(std::string const & title, bool const advanced_only)
549 {
551 [this, title]()
552 {
553 derived_t().print_subsection(title);
554 },
555 advanced_only,
556 false /* never hidden */);
557 }
558
562 void add_line(std::string const & text, bool is_paragraph, bool const advanced_only)
563 {
565 [this, text, is_paragraph]()
566 {
567 derived_t().print_line(text, is_paragraph);
568 },
569 advanced_only,
570 false /* never hidden */);
571 }
572
576 void add_list_item(std::string const & key, std::string const & desc, bool const advanced_only)
577 {
579 [this, key, desc]()
580 {
581 derived_t().print_list_item(key, desc);
582 },
583 advanced_only,
584 false /* never hidden */);
585 }
586
602
605
606protected:
609
612 {
613 return static_cast<derived_type &>(*this);
614 }
615
618 {
619 constexpr std::string_view end_format_sv = "\\fP";
620 for (unsigned i = 0; i < meta.synopsis.size(); ++i)
621 {
622 std::string text = "\\fB";
623 text.append(meta.synopsis[i]);
624 // Use iterator syntax instead of index. Index syntax is a segfault if there is no space or tab.
625 text.insert(text.begin() + text.find_first_of(" \t"), end_format_sv.begin(), end_format_sv.end());
626
627 derived_t().print_line(text, false);
628 }
629 }
630
634 void print_line(std::string const & text)
635 {
636 derived_t().print_line(text, true);
637 }
638
641 {
642 std::string const version_str{sharg::sharg_version_cstring};
643
644 // Print version, date and url.
645 derived_t().print_section("Version");
646 derived_t().print_line(derived_t().in_bold("Last update: ") + meta.date, false);
647 derived_t().print_line(derived_t().in_bold(meta.app_name + " version: ") + meta.version, false);
648 derived_t().print_line(derived_t().in_bold("Sharg version: ") + version_str, false);
649
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);
653#endif
654
655 if (!empty(meta.url))
656 {
657 derived_t().print_section("Url");
658 derived_t().print_line(meta.url, false);
659 }
660 }
661
664 {
665 // Print legal stuff
666 if ((!empty(meta.short_copyright)) || (!empty(meta.long_copyright)) || (!empty(meta.citation))
667 || (!empty(meta.author)) || (!empty(meta.email)))
668 {
669 derived_t().print_section("Legal");
670
671 if (!empty(meta.short_copyright))
672 {
673 derived_t().print_line(derived_t().in_bold(meta.app_name + " Copyright: ") + meta.short_copyright,
674 false);
675 }
676
677 if (!empty(meta.author))
678 {
679 derived_t().print_line(derived_t().in_bold("Author: ") + meta.author, false);
680 }
681
682 if (!empty(meta.email))
683 {
684 derived_t().print_line(derived_t().in_bold("Contact: ") + meta.email, false);
685 }
686
687 derived_t().print_line(derived_t().in_bold("SeqAn Copyright: ")
688 + "2006-2026 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.",
689 false);
690
691 if (!empty(meta.citation))
692 {
693 derived_t().print_line(derived_t().in_bold("In your academic works please cite: "), false);
694 for (size_t i = 0; i < meta.citation.size(); ++i)
695 {
696 // Using `\\fB` and `\\fP` instead of `derived_t().in_bold()` here.
697 // `format_help::print_list_item` uses `format_help::text_width` to determine whether
698 // there should be a new line after the key ("[i]").
699 // `format_help::text_width` ignores special sequences such as `\\fB` and `\\fP`,
700 // but not the actual control sequences produced by `derived_t().in_bold()`.
701 // All formats support `\\fB` and `\\fP`.
702 derived_t().print_list_item("\\fB[" + std::to_string(i + 1u) + "]\\fP", meta.citation[i]);
703 }
704 }
705
706 if (!empty(meta.long_copyright))
707 {
708 derived_t().print_line("For full copyright and/or warranty information see "
709 + derived_t().in_bold("--copyright") + ".",
710 false);
711 }
712 }
713 }
714
717 {
718 if (synopsis_elements.empty())
719 return;
720
721 std::string & first = executable_name[0];
722 first = first.substr(first.find_last_of('/') + 1);
723
724#ifdef __cpp_lib_ranges_join_with
725 auto view = std::views::join_with(executable_name, ' ');
726 std::string synopsis_line{view.begin(), view.end()};
727#else // libc++ implements std::views::join_with since version 21
728 std::string synopsis_line;
729 for (size_t i = 0; i < executable_name.size(); ++i)
730 {
731 if (i > 0)
732 synopsis_line += ' ';
733 synopsis_line += executable_name[i];
734 }
735#endif
736
742
743 for (auto it = synopsis_elements.begin(); it != pivot; ++it)
744 {
745 synopsis_line += " " + it->option_str;
746 }
747 if (pivot != synopsis_elements.end())
748 {
749 synopsis_line += " [\\fB--\\fP]";
750 for (auto it = pivot; it != synopsis_elements.end(); ++it)
751 {
752 synopsis_line += " " + it->option_str;
753 }
754 }
755
756 meta.synopsis.emplace_back(std::move(synopsis_line));
757 }
758
762 std::vector<std::function<void()>> positional_option_calls; // singled out to be printed on top
771 {
773 enum class option_type : uint8_t
774 {
775 flag,
776 option,
778 };
781 };
782
785
786private:
798 void store_help_page_element(std::function<void()> printer, bool const advanced, bool const hidden)
799 {
800 if (!(hidden) && (!(advanced) || show_advanced_options))
801 parser_set_up_calls.push_back(std::move(printer));
802 }
803
812 std::string const & type_str,
813 bool const required,
814 bool const is_list)
815 {
816 std::string opt_str = prep_id_for_help(id, true);
817
818 opt_str += " \\fI" + type_str + "\\fP";
819
820 if (!required)
821 {
822 opt_str = "[" + opt_str + "]";
823
824 if (is_list)
825 opt_str.append("...");
826 }
827 else if (is_list)
828 {
829 opt_str = opt_str + " [" + opt_str + "]...";
830 }
831
833 }
834
840 {
841 std::string flag_str = "[" + prep_id_for_help(id, true) + "]";
843 }
844
850 void store_synopsis_positional(std::string const & type_str, bool const is_list)
851 {
852 std::string pos_str = "\\fI" + type_str + "\\fP";
853
854 if (is_list)
855 pos_str += "...";
856
858 }
859
870 template <typename validator_t>
872 {
874 parser_set_up_calls.push_back(std::move(printer));
875 }
876};
877
878} // namespace sharg::detail
T append(T... args)
Provides auxiliary information.
T begin(T... args)
The format that contains all helper functions needed in all formats.
Definition format_base.hpp:32
static void print_as_uppercase(std::string const &str)
Prints a string to std::cout converted to uppercase.
Definition format_base.hpp:301
static std::string expand_multiple_flags(std::string const &flag_cluster)
Expands multiple one character flag identifiers for pretty help output.
Definition format_base.hpp:172
static std::string option_type_and_list_info(option_value_type const &)
Formats the type of a value for the help page printing.
Definition format_base.hpp:94
static std::string get_type_name_as_string()
Returns the input type as a string (reflection).
Definition format_base.hpp:40
static void print_as_lowercase(std::string const &str)
Prints a string to std::cout converted to lowercase.
Definition format_base.hpp:287
static std::string get_default_message(option_type const &option, default_type const &value)
Returns the default message for the help page.
Definition format_base.hpp:202
static std::string prep_id_for_help(detail::id_pair const &id, bool const is_synopsis=false)
Formats the option/flag identifier pair for the help page printing.
Definition format_base.hpp:119
static std::string option_type_and_list_info(container_type const &)
Formats the container and its value_type for the help page printing.
Definition format_base.hpp:105
static std::string escape_special_xml_chars(std::string const &original)
Escapes certain characters for correct output.
Definition format_base.hpp:142
The format that contains all helper functions needed in all formats for printing the interface descri...
Definition format_base.hpp:319
unsigned positional_option_count
Keeps track of the number of positional options.
Definition format_base.hpp:764
void parse(parser_meta_data &parser_meta, std::vector< std::string > const &executable_name)
Initiates the printing of the help page to std::cout.
Definition format_base.hpp:450
bool show_advanced_options
Whether to show advanced options or not.
Definition format_base.hpp:768
update_notifications version_check_dev_decision
Set on construction and indicates whether the developer deactivated the version check calls completel...
Definition format_base.hpp:608
std::vector< std::function< void()> > parser_set_up_calls
Vector of functions that stores all calls except add_positional_option.
Definition format_base.hpp:760
void store_synopsis_option(detail::id_pair const &id, std::string const &type_str, bool const required, bool const is_list)
Stores option information for synopsis generation.
Definition format_base.hpp:811
format_help_base(std::vector< std::string > const &names, update_notifications const version_updates, bool const advanced)
Initializes a format_help_base object.
Definition format_base.hpp:336
format_help_base & operator=(format_help_base const &pf)=default
Defaulted.
void print_legal()
Prints the legal information.
Definition format_base.hpp:663
format_help_base & operator=(format_help_base &&)=default
Defaulted.
void add_line(std::string const &text, bool is_paragraph, bool const advanced_only)
Adds a print_line call to parser_set_up_calls.
Definition format_base.hpp:562
derived_type & derived_t()
Returns the derived type.
Definition format_base.hpp:611
format_help_base(format_help_base &&)=default
Defaulted.
format_help_base(format_help_base const &pf)=default
Defaulted.
void add_positional_option(option_type &value, config< validator_t > const &config)
Adds a sharg::print_list_item call to be evaluated later on.
Definition format_base.hpp:401
parser_meta_data meta
Stores all meta information about the application.
Definition format_base.hpp:601
void add_option(option_type &value, config< validator_t > const &config)
Adds a sharg::print_list_item call to be evaluated later on.
Definition format_base.hpp:350
void store_synopsis_positional(std::string const &type_str, bool const is_list)
Stores positional argument information for synopsis generation.
Definition format_base.hpp:850
void print_synopsis()
Prints a synopsis in any format.
Definition format_base.hpp:617
void store_help_page_element(std::function< void()> printer, config< validator_t > const &config)
Adds a function object to parser_set_up_calls if the annotation in config does not prevent it.
Definition format_base.hpp:871
std::vector< std::string > command_names
The names of subcommand programs.
Definition format_base.hpp:766
format_help_base()=default
Defaulted.
void print_line(std::string const &text)
Delegates to sharg::print_line(std::string const & text, true) of each format.
Definition format_base.hpp:634
void generate_default_synopsis(std::vector< std::string > executable_name)
Generates default synopsis from stored elements.
Definition format_base.hpp:716
std::vector< std::function< void()> > positional_option_calls
Vector of functions that stores add_positional_option calls.
Definition format_base.hpp:762
~format_help_base()=default
Defaulted.
std::vector< synopsis_element > synopsis_elements
Stores elements for automatic synopsis generation.
Definition format_base.hpp:784
friend derived_type
Befriend the derived type so it can access private functions.
Definition format_base.hpp:604
void add_list_item(std::string const &key, std::string const &desc, bool const advanced_only)
Adds a sharg::print_list_item call to parser_set_up_calls.
Definition format_base.hpp:576
void add_flag(bool &value, config< validator_t > const &config)
Adds a sharg::print_list_item call to be evaluated later on.
Definition format_base.hpp:382
void store_synopsis_flag(detail::id_pair const &id)
Stores flag information for synopsis generation.
Definition format_base.hpp:839
void add_section(std::string const &title, bool const advanced_only)
Adds a print_section call to parser_set_up_calls.
Definition format_base.hpp:534
void print_version()
Prints the version information.
Definition format_base.hpp:640
void add_subsection(std::string const &title, bool const advanced_only)
Adds a print_subsection call to parser_set_up_calls.
Definition format_base.hpp:548
void store_help_page_element(std::function< void()> printer, bool const advanced, bool const hidden)
Adds a function object to parser_set_up_calls if the annotation in config does not prevent it.
Definition format_base.hpp:798
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 empty(T... args)
T end(T... args)
T erase(T... args)
T find_first_of(T... args)
T find_last_of(T... args)
T front(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.
T insert(T... args)
T is_same_v
T lower_bound(T... args)
T push_back(T... args)
T quoted(T... args)
T reserve(T... args)
T size(T... args)
T stable_sort(T... args)
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
Structure to store synopsis element information.
Definition format_base.hpp:771
option_type type
Type of the option.
Definition format_base.hpp:780
option_type
Kinds of options.
Definition format_base.hpp:774
std::string option_str
The formatted option string.
Definition format_base.hpp:779
A simple struct to store a short and a long identifier for an option.
Definition id_pair.hpp:25
Stores all parser related meta information of the sharg::parser.
Definition auxiliary.hpp:99
std::string email
The author's e-mail address for correspondence.
Definition auxiliary.hpp:117
std::vector< std::string > description
A more detailed description that is displayed on the help page in the section "DESCRIPTION"....
Definition auxiliary.hpp:151
std::vector< std::string > examples
Provide some examples on how to use your tool and what standard parameters might be appropriate in di...
Definition auxiliary.hpp:162
std::string app_name
The application name that will be displayed on the help page.
Definition auxiliary.hpp:105
std::string version
The version information MAJOR.MINOR.PATH (e.g. 3.1.3)
Definition auxiliary.hpp:108
std::vector< std::string > synopsis
Add lines of usage to the synopsis section of the help page (e.g. "./my_read_mapper [OPTIONS] FILE1 F...
Definition auxiliary.hpp:156
std::string long_copyright
Detailed copyright information that will be displayed when the user specifies "--copyright" on the co...
Definition auxiliary.hpp:133
std::string url
A link to your github/gitlab project with the newest release.
Definition auxiliary.hpp:125
std::string short_copyright
Brief copyright (and/or license) information.
Definition auxiliary.hpp:128
std::string date
The date that the application was last updated. Keep this updated, ! since it will tell your users th...
Definition auxiliary.hpp:122
std::string author
Your name ;-)
Definition auxiliary.hpp:114
vector_of_string citation
How users shall cite your application.
Definition auxiliary.hpp:136
T substr(T... args)
T to_string(T... args)
T transform(T... args)
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
Hide me