24namespace seqan3::detail
39class format_help :
public format_help_base<format_help>
42 using base_type = format_help_base<format_help>;
50 format_help() =
default;
51 format_help(format_help
const & pf) =
default;
52 format_help & operator=(format_help
const &) =
default;
53 format_help(format_help &&) =
default;
54 format_help & operator=(format_help &&) =
default;
55 ~format_help() =
default;
65 struct console_layout_struct
70 uint32_t defaultScreenWidth;
72 uint32_t maximalScreenWidth;
74 uint32_t minimalScreenWidth;
78 uint32_t centerPadding;
80 uint32_t rightPadding;
82 uint32_t leftColumnWidth;
84 uint32_t rightColumnWidth;
86 uint32_t rightColumnTab;
90 console_layout_struct(uint32_t
const terminal_width) :
91 screenWidth{0}, defaultScreenWidth{80}, maximalScreenWidth{120}, minimalScreenWidth{40},
92 leftPadding{4}, centerPadding{2}, rightPadding{2}, leftColumnWidth{4}, rightColumnWidth{0}
95 screenWidth = (terminal_width > 0) ? terminal_width : defaultScreenWidth;
96 screenWidth =
std::max(screenWidth, minimalScreenWidth);
97 screenWidth =
std::min(screenWidth, maximalScreenWidth);
98 screenWidth -= rightPadding;
100 rightColumnWidth = screenWidth - leftPadding - leftColumnWidth - centerPadding - rightPadding;
101 rightColumnTab = leftPadding + leftColumnWidth + centerPadding;
105 console_layout_struct() : console_layout_struct{get_terminal_width()} {}
114 if (!
empty(meta.short_description))
115 std::cout <<
" - " << meta.short_description;
118 unsigned len = text_width(meta.app_name) + (
empty(meta.short_description) ? 0 : 3) +
119 text_width(meta.short_description);
133 prev_was_paragraph =
false;
145 prev_was_paragraph =
false;
153 void print_line(
std::string const & text,
bool const line_is_paragraph)
155 if (prev_was_paragraph)
160 print_text(text, layout.leftPadding);
161 prev_was_paragraph = line_is_paragraph;
180 if (prev_was_paragraph)
188 unsigned pos = layout.leftPadding + term.
size();
189 if (pos + layout.centerPadding > layout.rightColumnTab)
194 std::fill_n(out, layout.rightColumnTab - pos,
' ');
195 print_text(desc, layout.rightColumnTab);
197 prev_was_paragraph =
false;
213 for (
auto it = str.
begin(); it != str.
end(); ++it)
219 assert(it != str.
end());
227 assert(it != str.
end());
272 for (
unsigned i = 0; i < text.
size(); ++i)
280 if (i + 1 == text.
size())
286 if (text[i + 1] ==
'\\' || text[i + 1] ==
'-')
293 if (i + 2 == text.
size())
300 if (text[i + 1] ==
'f')
302 if (text[i + 2] ==
'B' || text[i + 2] ==
'I' || text[i + 2] ==
'P')
316 void print_text(
std::string const & text,
unsigned const tab)
325 std::cpp20::back_inserter(tokens));
333 for (TConstIter it = tokens.
begin(); it != tokens.
end(); ++it)
335 if (it == tokens.
begin())
338 pos += text_width(*it);
339 if (pos > layout.screenWidth)
348 if (pos + 1 + text_width(*it) > layout.screenWidth)
354 pos = tab + text_width(*it);
360 pos += text_width(*it) + 1;
374 return to_text(
"\\fB") + str + to_text(
"\\fP");
378 bool prev_was_paragraph{
false};
381 friend struct ::seqan3::detail::test_accessor;
384 console_layout_struct layout{};
398class format_short_help :
public format_help
404 void parse(argument_parser_meta_data
const & parser_meta)
410 if (!parser_meta.synopsis.empty())
413 print_line(
"Try -h or --help for more information.\n",
true);
430class format_version :
public format_help
436 void parse(argument_parser_meta_data & parser_meta)
458class format_copyright :
public format_help
464 void parse(argument_parser_meta_data
const & parser_meta)
469R
"(Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
470Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
473Redistribution and use in source and binary forms, with or without
474modification, are permitted provided that the following conditions are met:
476 * Redistributions of source code must retain the above copyright
477 notice, this list of conditions and the following disclaimer.
478 * Redistributions in binary form must reproduce the above copyright
479 notice, this list of conditions and the following disclaimer in the
480 documentation and/or other materials provided with the distribution.
481 * Neither the name of Knut Reinert or the FU Berlin nor the names of
482 its contributors may be used to endorse or promote products derived
483 from this software without specific prior written permission.
485THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
486AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
487IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
488ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
489FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
490DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
491SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
492CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
493LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
494OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
498 << in_bold(
"Copyright information for " + meta.app_name +
":\n")
501 if (!
empty(meta.long_copyright))
503 stream << to_text(
"\\fP") << meta.long_copyright <<
"\n";
505 else if (!
empty(meta.short_copyright))
507 stream << in_bold(meta.app_name +
" full copyright information not available. " +
508 "Displaying short copyright information instead:\n" )
509 << meta.short_copyright <<
"\n";
513 stream << to_text(
"\\fP") << meta.app_name <<
" copyright information not available.\n";
517 << in_bold(
"This program contains SeqAn code licensed under the following terms:\n")
518 <<
std::string(80,
'-') <<
'\n' << seqan_license <<
'\n';
@ advanced
Definition: auxiliary.hpp:256
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
Forward declares seqan3::detail::test_accessor.