A generalized format to create different tool description files.
More...
#include <sharg/detail/format_tdl.hpp>
|
std::vector< std::function< void(std::string_view)> > | parser_set_up_calls |
| Vector of functions that stores all calls except add_positional_option.
|
|
std::vector< std::function< void(std::string_view)> > | 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.
|
|
tdl::ToolInfo | info |
| TDL DS filled with tool meta information.
|
|
tdl::Node::Children | parameters |
| all collected parameters
|
|
FileFormat | fileFormat |
| Targeted tool description format.
|
|
parser_meta_data | meta |
| Stores all meta information about the application.
|
|
|
| format_tdl (FileFormat fileFormat) |
| Construct from a file format.
|
|
| format_tdl (format_tdl const &)=default |
| Defaulted.
|
|
format_tdl & | operator= (format_tdl const &)=default |
| Defaulted.
|
|
| format_tdl (format_tdl &&)=default |
| Defaulted.
|
|
format_tdl & | operator= (format_tdl &&)=default |
| Defaulted.
|
|
| ~format_tdl ()=default |
| Defaulted.
|
|
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, std::vector< std::string > const &executable_name) |
| 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.
|
|
template<typename validator_t > |
void | store_help_page_element (std::function< void(std::string_view)> printer, config< validator_t > const &config) |
| Adds a function object to parser_set_up_calls if the annotation in spec does not prevent it.
|
|
A generalized format to create different tool description files.
This class allows to create different outputs format. See sharg::detail::format_tdl::FileFormat for available formats.
◆ FileFormat
Supported tool description file formats.
Enumerator |
---|
CTD | Support for CTD format.
|
CWL | Support for CWL format.
|
◆ format_tdl()
sharg::detail::format_tdl::format_tdl |
( |
FileFormat | fileFormat | ) |
|
|
inline |
Construct from a file format.
- Parameters
-
fileFormat | The file format. |
◆ add_flag()
template<typename validator_t >
void sharg::detail::format_tdl::add_flag |
( |
bool & | value, |
|
|
config< validator_t > const & | config ) |
|
inline |
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()
void sharg::detail::format_tdl::add_line |
( |
std::string const & | text, |
|
|
bool | is_paragraph, |
|
|
bool const | advanced_only ) |
|
inline |
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()
void sharg::detail::format_tdl::add_list_item |
( |
std::string const & | key, |
|
|
std::string const & | desc, |
|
|
bool const | advanced_only ) |
|
inline |
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 >
void sharg::detail::format_tdl::add_option |
( |
option_type & | value, |
|
|
config< validator_t > const & | config ) |
|
inline |
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 >
void sharg::detail::format_tdl::add_positional_option |
( |
option_type & | value, |
|
|
config< validator_t > const & | config ) |
|
inline |
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()
void sharg::detail::format_tdl::add_section |
( |
std::string const & | title, |
|
|
bool const | advanced_only ) |
|
inline |
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()
void sharg::detail::format_tdl::add_subsection |
( |
std::string const & | title, |
|
|
bool const | advanced_only ) |
|
inline |
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. |
[in] | executable_name | A list of arguments that form together the call to the executable. For example: [raptor, build] |
◆ store_help_page_element()
template<typename validator_t >
Adds a function object to parser_set_up_calls if the annotation in spec
does not prevent it.
- Parameters
-
[in] | printer | The invokable that, if added to parser_set_up_calls , prints information to the help page. |
[in] | config | The option specification deciding whether to add the information to the help page. |
If spec
equals sharg::option_spec::hidden
, the information is never added to the help page.
◆ 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: