7 #include "arg_router/policy/default_help_formatter.hpp"
11 namespace help_formatter_component
19 template <std::
size_t Indent>
22 static_assert(Indent > 0,
"Indent must be greater than zero");
24 constexpr
static auto reset_colour = std::string_view{
"\033[0m"};
25 constexpr
static auto red_colour = std::string_view{
"\033[31m"};
26 constexpr
static auto green_colour = std::string_view{
"\033[32m"};
37 template <std::
size_t DescStart, std::
size_t Depth,
typename HelpData>
38 void format(std::ostream& stream, std::size_t columns)
40 if constexpr (!HelpData::label::empty()) {
41 constexpr
auto indent = indent_size<Depth>();
42 stream << red_colour << utility::create_sequence_cts_t<indent, ' '>::get()
43 << HelpData::label::get();
45 if constexpr (!HelpData::description::empty()) {
46 static_assert(HelpData::description::get().find(
'\t') == std::string_view::npos,
47 "Help descriptions cannot contain tabs");
53 stream << green_colour << utility::create_sequence_cts_t<gap, ' '>::get();
63 stream << '\n' << utility::create_sequence_cts_t<DescStart, ' '>::get();
68 stream <<
"\n" << reset_colour;
82 std::size_t desc_start,
88 const auto indent = depth * Indent;
89 stream << red_colour << std::setw(indent) <<
' ' << help_data.
label;
96 stream << green_colour << std::setw(gap) <<
' ';
106 stream <<
'\n' << std::setw(desc_start) <<
' ';
111 stream <<
"\n" << reset_colour;
116 template <std::
size_t Depth>
117 [[nodiscard]] constexpr
static std::size_t indent_size() noexcept
119 return Depth * Indent;
138 typename PreambleFormatter = help_formatter_component::default_preamble_formatter,
139 typename AddendumFormatter = help_formatter_component::default_addendum_formatter>
bool empty() const noexcept
constexpr auto colour_help_formatter
std::integral_constant< decltype(Value), Value > integral_constant
constexpr std::size_t terminal_width(std::string_view str) noexcept
utility::dynamic_string_view label
Node name.
utility::dynamic_string_view description
Node description.