21namespace seqan3::detail
36class format_help :
public format_help_base<format_help>
39 using base_type = format_help_base<format_help>;
48 format_help() =
default;
49 format_help(format_help
const & pf) =
default;
50 format_help & operator=(format_help
const &) =
default;
51 format_help(format_help &&) =
default;
52 format_help & operator=(format_help &&) =
default;
53 ~format_help() =
default;
62 struct console_layout_struct
67 uint32_t defaultScreenWidth;
69 uint32_t maximalScreenWidth;
71 uint32_t minimalScreenWidth;
75 uint32_t centerPadding;
77 uint32_t rightPadding;
79 uint32_t leftColumnWidth;
81 uint32_t rightColumnWidth;
83 uint32_t rightColumnTab;
87 console_layout_struct(uint32_t
const terminal_width) :
89 defaultScreenWidth{80},
90 maximalScreenWidth{120},
91 minimalScreenWidth{40},
99 screenWidth = (terminal_width > 0) ? terminal_width : defaultScreenWidth;
100 screenWidth =
std::max(screenWidth, minimalScreenWidth);
101 screenWidth =
std::min(screenWidth, maximalScreenWidth);
102 screenWidth -= rightPadding;
104 rightColumnWidth = screenWidth - leftPadding - leftColumnWidth - centerPadding - rightPadding;
105 rightColumnTab = leftPadding + leftColumnWidth + centerPadding;
109 console_layout_struct() : console_layout_struct{get_terminal_width()}
119 if (!
empty(meta.short_description))
120 std::cout <<
" - " << meta.short_description;
124 text_width(meta.app_name) + (
empty(meta.short_description) ? 0 : 3) + text_width(meta.short_description);
141 return std::toupper(c);
144 prev_was_paragraph =
false;
156 prev_was_paragraph =
false;
164 void print_line(
std::string const & text,
bool const line_is_paragraph)
166 if (prev_was_paragraph)
171 print_text(text, layout.leftPadding);
172 prev_was_paragraph = line_is_paragraph;
191 if (prev_was_paragraph)
199 unsigned pos = layout.leftPadding + term.
size();
200 if (pos + layout.centerPadding > layout.rightColumnTab)
205 std::fill_n(out, layout.rightColumnTab - pos,
' ');
206 print_text(desc, layout.rightColumnTab);
208 prev_was_paragraph =
false;
224 for (
auto it = str.
begin(); it != str.
end(); ++it)
230 assert(it != str.
end());
238 assert(it != str.
end());
283 for (
unsigned i = 0; i < text.
size(); ++i)
291 if (i + 1 == text.
size())
297 if (text[i + 1] ==
'\\' || text[i + 1] ==
'-')
304 if (i + 2 == text.
size())
311 if (text[i + 1] ==
'f')
313 if (text[i + 2] ==
'B' || text[i + 2] ==
'I' || text[i + 2] ==
'P')
327 void print_text(
std::string const & text,
unsigned const tab)
345 for (TConstIter it = tokens.
begin(); it != tokens.
end(); ++it)
347 if (it == tokens.
begin())
350 pos += text_width(*it);
351 if (pos > layout.screenWidth)
360 if (pos + 1 + text_width(*it) > layout.screenWidth)
366 pos = tab + text_width(*it);
372 pos += text_width(*it) + 1;
386 return to_text(
"\\fB") + str + to_text(
"\\fP");
390 bool prev_was_paragraph{
false};
393 friend struct ::seqan3::detail::test_accessor;
396 console_layout_struct layout{};
410class format_short_help :
public format_help
416 void parse(argument_parser_meta_data
const & parser_meta)
422 if (!parser_meta.synopsis.empty())
425 print_line(
"Try -h or --help for more information.\n",
true);
442class format_version :
public format_help
448 void parse(argument_parser_meta_data & parser_meta)
470class format_copyright :
public format_help
476 void parse(argument_parser_meta_data
const & parser_meta)
481 R
"(Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
482Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
485Redistribution and use in source and binary forms, with or without
486modification, are permitted provided that the following conditions are met:
488 * Redistributions of source code must retain the above copyright
489 notice, this list of conditions and the following disclaimer.
490 * Redistributions in binary form must reproduce the above copyright
491 notice, this list of conditions and the following disclaimer in the
492 documentation and/or other materials provided with the distribution.
493 * Neither the name of Knut Reinert or the FU Berlin nor the names of
494 its contributors may be used to endorse or promote products derived
495 from this software without specific prior written permission.
497THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
498AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
499IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
500ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
501FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
502DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
503SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
504CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
505LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
506OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
510 << in_bold(
"Copyright information for " + meta.app_name +
":\n") <<
std::string(80,
'-') <<
'\n';
512 if (!
empty(meta.long_copyright))
514 stream << to_text(
"\\fP") << meta.long_copyright <<
"\n";
516 else if (!
empty(meta.short_copyright))
518 stream << in_bold(meta.app_name +
" full copyright information not available. "
519 +
"Displaying short copyright information instead:\n")
520 << meta.short_copyright <<
"\n";
524 stream << to_text(
"\\fP") << meta.app_name <<
" copyright information not available.\n";
528 << in_bold(
"This program contains SeqAn code licensed under the following terms:\n")
530 << seqan_license <<
'\n';
T back_inserter(T... args)
@ advanced
Definition auxiliary.hpp:254
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
Forward declares seqan3::detail::test_accessor.