A help message builder class.
More...
#include <help_builder.hpp>
|
| | help_builder (const std::string &name, const std::optional< std::string > &help=std::nullopt) |
| |
| void | add_param (const std::string ¶m_name, const std::string &value) |
| | Adds a parameter descriptor with the given string value.
|
| |
| template<util::c_writable T> |
| void | add_param (const std::string ¶m_name, const T &value) |
| | Adds a parameter descriptor with the given value.
|
| |
template<std::ranges::range R>
requires (util::c_writable<std::ranges::range_value_t<R>>) |
| void | add_range_param (const std::string ¶m_name, const R &range, const std::string_view delimiter=default_delimiter) |
| | Adds a range parameter descriptor with the given value.
|
| |
| std::string | get_basic (const uint8_t indent_width, const std::optional< std::size_t > align_to=std::nullopt) const |
| |
| std::string | get (const uint8_t indent_width, std::optional< std::size_t > max_line_width=std::nullopt) const |
| |
|
| std::string | _get_single_line (const uint8_t indent_width) const |
| | Generates a single-line string representation of the argument and its parameters.
|
| |
| std::string | _get_multi_line (const uint8_t indent_width) const |
| | Generates a multi-line string representation of the argument and its parameters, formatting each parameter on its own line with aligned names.
|
| |
A help message builder class.
Definition at line 32 of file help_builder.hpp.
◆ help_builder()
| ap::detail::help_builder::help_builder |
( |
const std::string & |
name, |
|
|
const std::optional< std::string > & |
help = std::nullopt |
|
) |
| |
|
inline |
- Parameters
-
| name | The string representation of the argument's name. |
| help | An optional help message string. |
Definition at line 38 of file help_builder.hpp.
◆ _get_multi_line()
| std::string ap::detail::help_builder::_get_multi_line |
( |
const uint8_t |
indent_width | ) |
const |
|
inlineprivate |
Generates a multi-line string representation of the argument and its parameters, formatting each parameter on its own line with aligned names.
- Parameters
-
| indent_width | Number of spaces before the argument name and additional indentation for parameters. |
- Returns
- A multi-line formatted description string.
Definition at line 170 of file help_builder.hpp.
◆ _get_single_line()
| std::string ap::detail::help_builder::_get_single_line |
( |
const uint8_t |
indent_width | ) |
const |
|
inlineprivate |
Generates a single-line string representation of the argument and its parameters.
- Parameters
-
| indent_width | Number of spaces before the argument name. |
- Returns
- A single-line formatted description string.
Definition at line 148 of file help_builder.hpp.
◆ add_param() [1/2]
| void ap::detail::help_builder::add_param |
( |
const std::string & |
param_name, |
|
|
const std::string & |
value |
|
) |
| |
|
inline |
Adds a parameter descriptor with the given string value.
- Parameters
-
| param_name | The parameter's name. |
| value | The parameter's value's string representation. |
Definition at line 46 of file help_builder.hpp.
◆ add_param() [2/2]
template<util::c_writable T>
| void ap::detail::help_builder::add_param |
( |
const std::string & |
param_name, |
|
|
const T & |
value |
|
) |
| |
|
inline |
Adds a parameter descriptor with the given value.
- Template Parameters
-
- Parameters
-
| param_name | The parameter's name. |
| value | The parameter's value. |
Definition at line 57 of file help_builder.hpp.
◆ add_range_param()
template<std::ranges::range R>
requires (util::c_writable<std::ranges::range_value_t<R>>)
| void ap::detail::help_builder::add_range_param |
( |
const std::string & |
param_name, |
|
|
const R & |
range, |
|
|
const std::string_view |
delimiter = default_delimiter |
|
) |
| |
|
inline |
Adds a range parameter descriptor with the given value.
- Template Parameters
-
| R | The type of the parameter range. The value type of R must satisfy the ap::util::c_writable concept. |
- Parameters
-
| param_name | The parameter's name. |
| range | The parameter value range. |
| delimiter | The delimiter used to separate the range values. |
Definition at line 72 of file help_builder.hpp.
◆ get()
| std::string ap::detail::help_builder::get |
( |
const uint8_t |
indent_width, |
|
|
std::optional< std::size_t > |
max_line_width = std::nullopt |
|
) |
| const |
|
inline |
Generates a full string representation of the argument descriptor, optionally formatted to fit within a specified maximum line width. The output includes the argument name, help message (if present), and any added parameters.
If no parameters are present, or the generated one-line representation fits within the max_line_width, a single-line format is used: "<indent><arg-name> : <help-msg> (<param1>: <value1>, ...)"
Otherwise, a multi-line format is returned, listing each parameter on its own line with additional indentation.
- Parameters
-
| indent_width | The number of spaces to insert before the argument name. |
| max_line_width | Optional maximum number of characters allowed for the one-line representation. If the one-line output exceeds this, a multi-line format is used instead. |
- Returns
- A formatted string describing the argument and its parameters.
- Note
- The help message is only included if it is not
std::nullopt.
Definition at line 120 of file help_builder.hpp.
◆ get_basic()
| std::string ap::detail::help_builder::get_basic |
( |
const uint8_t |
indent_width, |
|
|
const std::optional< std::size_t > |
align_to = std::nullopt |
|
) |
| const |
|
inline |
- Parameters
-
| indent_width | The indentation width. |
| align_to | Optional minimum width for the argument name; if provided, the name will be left-aligned and padded with spaces to this width. |
- Returns
- A basic argument description in the format "<indent><arg-name> : <help-msg>"
- Note
- The help message will only be visible in the output if it's not
std::nullopt
Definition at line 86 of file help_builder.hpp.
◆ default_delimiter
| constexpr std::string_view ap::detail::help_builder::default_delimiter = ", " |
|
staticconstexprprivate |
◆ help
| std::optional<std::string> ap::detail::help_builder::help |
◆ name
| std::string ap::detail::help_builder::name |
◆ params
The documentation for this class was generated from the following file: