SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::format_help Class Reference

The format that prints the help page to std::cout. More...

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

+ Inheritance diagram for seqan3::detail::format_help:

Classes

struct  console_layout_struct
 Stores the relevant parameters of the documentation on the screen. More...
 

Public Member Functions

Constructors, destructor and assignment
 format_help ()=default
 Defaulted.
 
 format_help (format_help const &pf)=default
 Defaulted.
 
format_helpoperator= (format_help const &)=default
 Defaulted.
 
 format_help (format_help &&)=default
 Defaulted.
 
format_helpoperator= (format_help &&)=default
 Defaulted.
 
 ~format_help ()=default
 Defaulted.
 
 format_help (std::vector< std::string > const &names, bool const advanced=false)
 Initializes a format_help_base object.
 
- Public Member Functions inherited from seqan3::detail::format_help_base< format_help >
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.
 
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.
 
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.
 

Private Types

using base_type = format_help_base< format_help >
 The CRTP base class type.
 

Private Member Functions

std::string in_bold (std::string const &str)
 Format string in bold.
 
void print_footer ()
 Prints a help page footer to std::cout.
 
void print_header ()
 Prints a help page header to std::cout.
 
void print_line (std::string const &text, bool const line_is_paragraph)
 Prints a text to std::cout.
 
void print_list_item (std::string const &term, std::string const &desc)
 Prints a help page list_item to std::cout.
 
void print_section (std::string const &title)
 Prints a help page section to std::cout.
 
void print_subsection (std::string const &title)
 Prints a help page subsection to std::cout.
 
void print_text (std::string const &text, unsigned const tab)
 Prints text with correct line wrapping to the command line (std::cout).
 
unsigned text_width (std::string const &text)
 Returns width of text if printed.
 
std::string to_text (std::string const &str)
 Formats text for pretty command line printing.
 

Private Attributes

friend base_type
 Befriend the base class to give access to the private member functions.
 
console_layout_struct layout {}
 Stores the relevant parameters of the documentation on the screen.
 
bool prev_was_paragraph {false}
 Needed for correct formatting while calling different print functions.
 

Friends

struct ::seqan3::detail::test_accessor
 Befriend seqan3::detail::test_accessor to grant access to layout.
 

Additional Inherited Members

- Public Attributes inherited from seqan3::detail::format_help_base< format_help >
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 inherited from seqan3::detail::format_help_base< format_help >
format_helpderived_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.
 
- 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.
 
- Protected Attributes inherited from seqan3::detail::format_help_base< format_help >
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
 Keeps track of the number of positional options.
 
bool show_advanced_options
 Whether to show advanced options or not.
 

Detailed Description

The format that prints the help page to std::cout.

The help page printing is not done immediately, because the user might not provide meta information, positional options, etc. in the correct order. In addition the needed order would be different from the parse format. Thus the calls are stored (parser_set_up_calls and positional_option_calls) and only evaluated when calling format_help::parse().

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

Constructor & Destructor Documentation

◆ format_help()

seqan3::detail::format_help::format_help ( std::vector< std::string > const &  names,
bool const  advanced = false 
)
inline

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

◆ in_bold()

std::string seqan3::detail::format_help::in_bold ( std::string const &  str)
inlineprivate

Format string in bold.

Parameters
[in]strThe input string to format in bold.
Returns
The string str wrapped in bold formatting.

◆ print_line()

void seqan3::detail::format_help::print_line ( std::string const &  text,
bool const  line_is_paragraph 
)
inlineprivate

Prints a text to std::cout.

Parameters
[in]textThe text to print.
[in]line_is_paragraphWhether to insert as paragraph or just a line (only one line break if not a paragraph).

◆ print_list_item()

void seqan3::detail::format_help::print_list_item ( std::string const &  term,
std::string const &  desc 
)
inlineprivate

Prints a help page list_item to std::cout.

Parameters
[in]termThe key of the key-value pair of the list item.
[in]descThe value of the key-value pair of the list item.

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

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

◆ print_section()

void seqan3::detail::format_help::print_section ( std::string const &  title)
inlineprivate

Prints a help page section to std::cout.

Parameters
[in]titleThe title of the subsection of the help page.

◆ print_subsection()

void seqan3::detail::format_help::print_subsection ( std::string const &  title)
inlineprivate

Prints a help page subsection to std::cout.

Parameters
[in]titleThe title of the subsection of the help page.

◆ print_text()

void seqan3::detail::format_help::print_text ( std::string const &  text,
unsigned const  tab 
)
inlineprivate

Prints text with correct line wrapping to the command line (std::cout).

Parameters
[in]textThe string to print on the command line.
[in]tabThe position offset (indentation) to start printing at.

◆ text_width()

unsigned seqan3::detail::format_help::text_width ( std::string const &  text)
inlineprivate

Returns width of text if printed.

Parameters
[in]textThe string to compute the width for on the command line. /detail Note: "\-" has length 1, "\fI", "\fB", "\fP" have length 0.

◆ to_text()

std::string seqan3::detail::format_help::to_text ( std::string const &  str)
inlineprivate

Formats text for pretty command line printing.

Parameters
[in]strThe input string to format for correct command line printing.

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