SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::format_help_base< derived_type > Class Template Reference

The format that contains all helper functions needed in all formats for printing the interface description of the application (to std::cout). More...

#include <seqan3/argument_parser/detail/format_base.hpp>

+ Inheritance diagram for seqan3::detail::format_help_base< derived_type >:

Public Member Functions

void add_flag (bool &value, char const short_id, std::string const &long_id, std::string const &desc, option_spec const spec)
 Adds a seqan3::print_list_item call to be evaluated later on.
 
void add_line (std::string const &text, bool is_paragraph, option_spec const spec)
 Adds a print_line call to parser_set_up_calls.
 
void add_list_item (std::string const &key, std::string const &desc, option_spec const spec)
 Adds a seqan3::print_list_item call to parser_set_up_calls.
 
template<typename option_type , typename validator_type >
void add_option (option_type &value, char const short_id, std::string const &long_id, std::string const &desc, option_spec const spec, validator_type &&option_validator)
 Adds a seqan3::print_list_item call to be evaluated later on.
 
template<typename option_type , typename validator_type >
void add_positional_option (option_type &value, std::string const &desc, validator_type &option_validator)
 Adds a seqan3::print_list_item call to be evaluated later on.
 
void add_section (std::string const &title, option_spec const spec)
 Adds a print_section call to parser_set_up_calls.
 
void add_subsection (std::string const &title, option_spec const spec)
 Adds a print_subsection call to parser_set_up_calls.
 
void parse (argument_parser_meta_data &parser_meta)
 Initiates the printing of the help page to std::cout.
 

Public Attributes

friend derived_type
 Befriend the derived type so it can access private functions.
 
argument_parser_meta_data meta
 Stores all meta information about the application.
 

Protected Member Functions

derived_typederived_t ()
 Returns the derived type.
 
void print_legal ()
 Prints the legal information.
 
void print_line (std::string const &text)
 Delegates to seqan3::print_line(std::string const & text, true) of each format.
 
void print_synopsis ()
 Prints a synopsis in any format.
 
void print_version ()
 Prints the version information.
 
- Protected Member Functions inherited from seqan3::detail::format_base
std::string escape_special_xml_chars (std::string const &original)
 Escapes certain characters for correct output.
 

Protected Attributes

std::vector< std::stringcommand_names {}
 The names of subcommand programs.
 
std::vector< std::function< void()> > parser_set_up_calls
 Vector of functions that stores all calls except add_positional_option.
 
std::vector< std::function< void()> > positional_option_calls
 Vector of functions that stores add_positional_option calls.
 
unsigned positional_option_count {0}
 Keeps track of the number of positional options.
 
bool show_advanced_options {true}
 Whether to show advanced options or not.
 

Private Member Functions

void store_help_page_element (std::function< void()> printer, option_spec const spec)
 Adds a function object to parser_set_up_calls if the annotation in spec does not prevent it.
 
Constructors, destructor and assignment
 format_help_base ()=default
 Defaulted.
 
 format_help_base (format_help_base const &pf)=default
 Defaulted.
 
format_help_baseoperator= (format_help_base const &pf)=default
 Defaulted.
 
 format_help_base (format_help_base &&)=default
 Defaulted.
 
format_help_baseoperator= (format_help_base &&)=default
 Defaulted.
 
 ~format_help_base ()=default
 Defaulted.
 
 format_help_base (std::vector< std::string > const &names, bool const advanced)
 Initializes a format_help_base object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from seqan3::detail::format_base
static std::string expand_multiple_flags (std::string const &flag_cluster)
 Expands multiple one character flag identifiers for pretty help output.
 
template<detail::is_container_option container_type>
static std::string get_type_name_as_string (container_type const &)
 Returns the value_type of the input container as a string (reflection).
 
template<typename value_type >
static std::string get_type_name_as_string (value_type const &)
 Returns the input type as a string (reflection).
 
template<detail::is_container_option container_type>
static std::string option_type_and_list_info (container_type const &container)
 Formats the container and its value_type for the help page printing.
 
template<typename option_value_type >
static std::string option_type_and_list_info (option_value_type const &value)
 Formats the type of a value for the help page printing.
 
static std::string prep_id_for_help (char const short_id, std::string const &long_id)
 Formats the option/flag identifier pair for the help page printing.
 

Detailed Description

template<typename derived_type>
class seqan3::detail::format_help_base< derived_type >

The format that contains all helper functions needed in all formats for printing the interface description of the application (to std::cout).

Remarks
For a complete overview, take a look at Argument Parser

Constructor & Destructor Documentation

◆ format_help_base()

template<typename derived_type >
seqan3::detail::format_help_base< derived_type >::format_help_base ( std::vector< std::string > const &  names,
bool const  advanced 
)
inlineprivate

Initializes a format_help_base object.

Parameters
[in]namesA list of subcommands (see subcommand parsing ).
[in]advancedSet to true to show advanced options.

Member Function Documentation

◆ add_flag()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::add_flag ( bool &  value,
char const  short_id,
std::string const &  long_id,
std::string const &  desc,
option_spec const  spec 
)
inline

Adds a seqan3::print_list_item call to be evaluated later on.

Parameters
[in,out]valueThe variable which shows whether the flag is turned off (default) or on.
[in]short_idThe short identifier for the flag (e.g. 'i').
[in]long_idThe long identifier for the flag (e.g. "integer").
[in]descThe description of the flag to be shown in the help page.
[in]specAdvanced flag specification, see seqan3::option_spec.
Exceptions
seqan3::design_errorif value is true.

◆ add_line()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::add_line ( std::string const &  text,
bool  is_paragraph,
option_spec const  spec 
)
inline

Adds a print_line call to parser_set_up_calls.

Parameters
[in]textThe text to print.
[in]is_paragraphWhether to insert as paragraph or just a line (Default: false).
[in]specWhether to always display this line (seqan3::option_spec::standard), only when showing the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden).

If the line is not a paragraph (false), only one line break is appended, otherwise two line breaks are appended. This only affects the help page and other output formats.

◆ add_list_item()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::add_list_item ( std::string const &  key,
std::string const &  desc,
option_spec const  spec 
)
inline

Adds a seqan3::print_list_item call to parser_set_up_calls.

Parameters
[in]keyThe key of the key-value pair of the list item.
[in]descThe value of the key-value pair of the list item.
[in]specWhether to always display this list item (seqan3::option_spec::standard), only when showing the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden).

Note: This only affects the help page and other output formats.

A list item is composed of a key (key) and value (desc) and usually used for option identifier-description-pairs. E.g.:

-a, --age LONG
Super important integer for age.

◆ add_option()

template<typename derived_type >
template<typename option_type , typename validator_type >
void seqan3::detail::format_help_base< derived_type >::add_option ( option_type &  value,
char const  short_id,
std::string const &  long_id,
std::string const &  desc,
option_spec const  spec,
validator_type &&  option_validator 
)
inline

Adds a seqan3::print_list_item call to be evaluated later on.

Template Parameters
option_typeMust have a formatted input function (stream >> value). If option_type is a container, its value type must have the formatted input function (exception: std::string is not regarded as a container). See FormattedInputFunction .
validator_typeThe type of validator to be applied to the option value. Must model seqan3::validator.
Parameters
[in,out]valueThe variable in which to store the given command line argument.
[in]short_idThe short identifier for the option (e.g. 'a').
[in]long_idThe long identifier for the option (e.g. "age").
[in]descThe description of the option to be shown in the help page.
[in]specAdvanced option specification, see seqan3::option_spec.
[in]option_validatorA seqan3::validator that verifies the value after parsing (callable).
Exceptions
seqan3::design_error

◆ add_positional_option()

template<typename derived_type >
template<typename option_type , typename validator_type >
void seqan3::detail::format_help_base< derived_type >::add_positional_option ( option_type &  value,
std::string const &  desc,
validator_type &  option_validator 
)
inline

Adds a seqan3::print_list_item call to be evaluated later on.

Template Parameters
option_typeMust have a formatted input function (stream >> value). If option_type is a container, its value type must have the formatted input function (exception: std::string is not regarded as a container). See FormattedInputFunction .
validator_typeThe type of validator to be applied to the option value. Must model seqan3::validator.
Parameters
[in,out]valueThe variable in which to store the given command line argument.
[in]descThe description of the positional option to be shown in the help page.
[in]option_validatorA seqan3::validator that verifies the value after parsing (callable).
Exceptions
seqan3::design_error

The validator must be applicable to the given output variable (value).

◆ add_section()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::add_section ( std::string const &  title,
option_spec const  spec 
)
inline

Adds a print_section call to parser_set_up_calls.

Parameters
[in]titleThe title of the section.
[in]specWhether to always display this section title (seqan3::option_spec::standard), only when showing the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden).

This only affects the help page and other output formats.

◆ add_subsection()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::add_subsection ( std::string const &  title,
option_spec const  spec 
)
inline

Adds a print_subsection call to parser_set_up_calls.

Parameters
[in]titleThe title of the subsection.
[in]specWhether to always display this subsection title (seqan3::option_spec::standard), only when showing the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden).

This only affects the help page and other output formats.

◆ parse()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::parse ( argument_parser_meta_data parser_meta)
inline

Initiates the printing of the help page to std::cout.

Parameters
[in]parser_metaThe meta information that are needed for a detailed help page.

◆ print_line()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::print_line ( std::string const &  text)
inlineprotected

Delegates to seqan3::print_line(std::string const & text, true) of each format.

Parameters
[in]textThe text to print.

◆ store_help_page_element()

template<typename derived_type >
void seqan3::detail::format_help_base< derived_type >::store_help_page_element ( std::function< void()>  printer,
option_spec const  spec 
)
inlineprivate

Adds a function object to parser_set_up_calls if the annotation in spec does not prevent it.

Parameters
[in]printerThe invokable that, if added to parser_set_up_calls, prints information to the help page.
[in]specThe option specification deciding whether to add the information to the help page.

If spec equals seqan3::option_spec::hidden, the information is never added to the help page. If spec equals seqan3::option_spec::advanced, the information is only added to the help page if the advanced help page has been queried on the command line (show_advanced_options == true).

Member Data Documentation

◆ meta

Stores all meta information about the application.

This needs to be a member of format_parse, because it needs to present (not filled) when the parser_set_up_calls vector is filled, since all printing functions need some meta information. The member variable itself is filled when copied over from the argument_parser when calling format_parse::parse. That way all the information needed are there, when the actual printing starts.

This function is not private because it is needed for short but nicely formatted (error) output to the command line.


The documentation for this class was generated from the following file:
Hide me