The format that contains all helper functions needed in all formats for printing the interface description of the application (to std::cout).
More...
#include <sharg/detail/format_base.hpp>
|
template<typename option_type , typename validator_t > |
void | add_option (option_type &value, config< validator_t > const &config) |
| Adds a sharg::print_list_item call to be evaluated later on.
|
|
template<typename validator_t > |
void | add_flag (bool &value, config< validator_t > const &config) |
| Adds a sharg::print_list_item call to be evaluated later on.
|
|
template<typename option_type , typename validator_t > |
void | add_positional_option (option_type &value, config< validator_t > const &config) |
| Adds a sharg::print_list_item call to be evaluated later on.
|
|
void | parse (parser_meta_data &parser_meta) |
| Initiates the printing of the help page to std::cout.
|
|
void | add_section (std::string const &title, bool const advanced_only) |
| Adds a print_section call to parser_set_up_calls.
|
|
void | add_subsection (std::string const &title, bool const advanced_only) |
| Adds a print_subsection call to parser_set_up_calls.
|
|
void | add_line (std::string const &text, bool is_paragraph, bool const advanced_only) |
| Adds a print_line call to parser_set_up_calls.
|
|
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.
|
|
|
parser_meta_data | meta |
| Stores all meta information about the application.
|
|
friend | derived_type |
| Befriend the derived type so it can access private functions.
|
|
|
derived_type & | derived_t () |
| Returns the derived type.
|
|
void | print_synopsis () |
| Prints a synopsis in any format.
|
|
void | print_line (std::string const &text) |
| Delegates to sharg::print_line(std::string const & text, true) of each format.
|
|
void | print_version () |
| Prints the version information.
|
|
void | print_legal () |
| Prints the legal information.
|
|
|
update_notifications | version_check_dev_decision {} |
| Set on construction and indicates whether the developer deactivated the version check calls completely.
|
|
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.
|
|
std::vector< std::string > | command_names {} |
| The names of subcommand programs.
|
|
bool | show_advanced_options {true} |
| Whether to show advanced options or not.
|
|
template<typename
derived_type>
class sharg::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).
◆ format_help_base()
Initializes a format_help_base object.
- Parameters
-
[in] | names | A list of subcommands (see subcommand parsing ). |
[in] | version_updates | Whether the developer disabled version checks when constructing the parser. |
[in] | advanced | Set to true to show advanced options. |
◆ add_flag()
template<typename validator_t >
Adds a sharg::print_list_item call to be evaluated later on.
- Parameters
-
[in,out] | value | The variable which shows if the flag is turned off (default) or on. |
[in] | config | A configuration object to customise the sharg::parser behaviour. See sharg::config. |
- Exceptions
-
This entity is stable. Since version 1.0.
◆ add_line()
Adds a print_line call to parser_set_up_calls.
- Parameters
-
[in] | text | The text to print. |
[in] | is_paragraph | Whether to insert as paragraph or just a line (Default: false). |
[in] | advanced_only | If set to true, the section only shows when the user requested the advanced help page. |
- Exceptions
-
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.
This entity is stable. Since version 1.0.
◆ add_list_item()
Adds a sharg::print_list_item call to parser_set_up_calls.
- Parameters
-
[in] | key | The key of the key-value pair of the list item. |
[in] | desc | The value of the key-value pair of the list item. |
[in] | advanced_only | If set to true, the section only shows when the user requested the advanced help page. |
- Exceptions
-
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.
This entity is stable. Since version 1.0.
◆ add_option()
template<typename option_type , typename validator_t >
Adds a sharg::print_list_item call to be evaluated later on.
- Template Parameters
-
option_type | Must 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_type | The type of validator to be applied to the option value. Must model sharg::validator. |
- Parameters
-
[in,out] | value | The variable in which to store the given command line argument. |
[in] | config | A configuration object to customise the sharg::parser behaviour. See sharg::config. |
The config.validator
must be applicable to the given output variable (value
).
- Exceptions
-
This entity is stable. Since version 1.0.
◆ add_positional_option()
template<typename option_type , typename validator_t >
Adds a sharg::print_list_item call to be evaluated later on.
- Template Parameters
-
option_type | Must 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_type | The type of validator to be applied to the option value. Must model sharg::validator. |
- Parameters
-
[in,out] | value | The variable in which to store the given command line argument. |
[in] | config | Customise the sharg::parser behaviour. See sharg::positional_config. |
- Exceptions
-
The config.validator
must be applicable to the given output variable (value
).
This entity is stable. Since version 1.0.
◆ add_section()
Adds a print_section call to parser_set_up_calls.
- Parameters
-
[in] | title | The title of the section. |
[in] | advanced_only | If set to true, the section only shows when the user requested the advanced help page. |
- Exceptions
-
This only affects the help page and other output formats.
This entity is stable. Since version 1.0.
◆ add_subsection()
Adds a print_subsection call to parser_set_up_calls.
- Parameters
-
[in] | title | The title of the subsection. |
[in] | advanced_only | If set to true, the section only shows when the user requested the advanced help page. |
- Exceptions
-
This only affects the help page and other output formats.
This entity is stable. Since version 1.0.
◆ parse()
Initiates the printing of the help page to std::cout.
- Parameters
-
[in] | parser_meta | The meta information that are needed for a detailed help page. |
◆ print_line()
Delegates to sharg::print_line(std::string const & text, true) of each format.
- Parameters
-
[in] | text | The text to print. |
◆ store_help_page_element() [1/2]
Adds a function object to parser_set_up_calls if the annotation in config
does not prevent it.
- Parameters
-
[in] | printer | The invokable that, if added to parser_set_up_calls , prints information to the help page. |
[in] | advanced | Whether the help page element was configured to be hidden. |
[in] | hidden | Whether the help page element was configured to be hidden. |
If hidden = true
, the information is never added to the help page. If advanced = true
, 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
).
◆ store_help_page_element() [2/2]
template<typename validator_t >
Adds a function object to parser_set_up_calls if the annotation in config
does not prevent it.
- Parameters
-
If config.hidden = true
, the information is never added to the help page. If config.advanced = true
, 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
).
◆ 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 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: