39 class format_help :
public format_help_base<format_help>
42 using base_type = format_help_base<format_help>;
51 format_help() =
default;
52 format_help(format_help
const & pf) =
default;
53 format_help & operator=(format_help
const &) =
default;
54 format_help(format_help &&) =
default;
55 format_help & operator=(format_help &&) =
default;
56 ~format_help() =
default;
66 struct console_layout_struct
71 unsigned defaultScreenWidth;
73 unsigned maximalScreenWidth;
75 unsigned minimalScreenWidth;
79 unsigned centerPadding;
81 unsigned rightPadding;
83 unsigned leftColumnWidth;
85 unsigned rightColumnWidth;
87 unsigned rightColumnTab;
90 console_layout_struct() :
91 screenWidth{0}, defaultScreenWidth{80}, maximalScreenWidth{120}, minimalScreenWidth{40},
92 leftPadding{4}, centerPadding{2}, rightPadding{2}, leftColumnWidth{4}, rightColumnWidth{0}
95 unsigned cols = get_terminal_width();
96 screenWidth = (cols > 0) ? cols : defaultScreenWidth;
97 screenWidth =
std::max(screenWidth, minimalScreenWidth);
98 screenWidth =
std::min(screenWidth, maximalScreenWidth);
99 screenWidth -= rightPadding;
101 rightColumnWidth = screenWidth - leftPadding - leftColumnWidth - centerPadding - rightPadding;
102 rightColumnTab = leftPadding + leftColumnWidth + centerPadding;
112 if (!
empty(meta.short_description))
113 std::cout <<
" - " << meta.short_description;
116 unsigned len = text_width(meta.app_name) + (
empty(meta.short_description) ? 0 : 3) +
117 text_width(meta.short_description);
131 prev_was_paragraph =
false;
142 std::cout << title << to_text(
"\\fP") <<
'\n';
143 prev_was_paragraph =
false;
151 void print_line(
std::string const & text,
bool const line_is_paragraph)
153 if (prev_was_paragraph)
158 print_text(text, layout.leftPadding);
159 prev_was_paragraph = line_is_paragraph;
178 if (prev_was_paragraph)
186 unsigned pos = layout.leftPadding + term.
size();
187 if (pos + layout.centerPadding > layout.rightColumnTab)
192 std::fill_n(out, layout.rightColumnTab - pos,
' ');
193 print_text(desc, layout.rightColumnTab);
195 prev_was_paragraph =
false;
204 std::cout <<
"\n" << to_text(
"\\fB") <<
"VERSION" << to_text(
"\\fP") <<
"\n";
206 std::cout << to_text(
"\\fB") <<
"Last update: " << to_text(
"\\fP") << meta.date <<
"\n";
208 std::cout << to_text(
"\\fB") << meta.app_name <<
" version: " << to_text(
"\\fP") << meta.version <<
"\n";
213 if (!
empty(meta.url))
215 std::cout <<
"\n" << to_text(
"\\fB") <<
"URL" << to_text(
"\\fP") <<
"\n";
230 if ((!
empty(meta.short_copyright)) || (!
empty(meta.long_copyright)) || (!
empty(meta.citation)))
232 std::cout <<
"\n" << to_text(
"\\fB") <<
"LEGAL" << to_text(
"\\fP") <<
"\n";
234 if (!
empty(meta.short_copyright))
237 std::cout << to_text(
"\\fB") << meta.app_name <<
" Copyright: " 238 << to_text(
"\\fP") << meta.short_copyright <<
"\n";
241 std::cout << to_text(
"\\fB") <<
"SeqAn Copyright: " << to_text(
"\\fP")
242 <<
"2006-2015 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.\n";
243 if (!
empty(meta.citation))
246 std::cout << to_text(
"\\fB") <<
"In your academic works please cite: " << to_text(
"\\fP")
247 << meta.citation <<
"\n";
249 if (!
empty(meta.long_copyright))
252 std::cout <<
"For full copyright and/or warranty information see " << to_text(
"\\fB")
253 <<
"--copyright" << to_text(
"\\fP") <<
".\n";
265 for (
auto it = str.
begin(); it != str.
end(); ++it)
271 assert(it != str.
end());
279 assert(it != str.
end());
324 for (
unsigned i = 0; i < text.
size(); ++i)
332 if (i + 1 == text.
size())
338 if (text[i + 1] ==
'\\' || text[i + 1] ==
'-')
345 if (i + 2 == text.
size())
352 if (text[i + 1] ==
'f')
354 if (text[i + 2] ==
'B' || text[i + 2] ==
'I' || text[i + 2] ==
'P')
368 void print_text(
std::string const & text,
unsigned const tab)
377 std::ranges::back_inserter(tokens));
385 for (TConstIter it = tokens.begin(); it != tokens.end(); ++it)
387 if (it == tokens.begin())
390 pos += text_width(*it);
391 if (pos > layout.screenWidth)
400 if (pos + 1 + text_width(*it) > layout.screenWidth)
406 pos = tab + text_width(*it);
412 pos += text_width(*it) + 1;
421 bool prev_was_paragraph{
false};
423 console_layout_struct layout{};
435 class format_short_help :
public format_help
441 void parse(argument_parser_meta_data
const & parser_meta)
447 if (!parser_meta.synopsis.empty())
450 print_line(
"Try -h or --help for more information.\n",
true);
465 class format_version :
public format_help
471 void parse(argument_parser_meta_data & parser_meta)
491 class format_copyright :
public format_help
497 void parse(argument_parser_meta_data
const & parser_meta)
502 R
"(Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin 503 Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik 506 Redistribution and use in source and binary forms, with or without 507 modification, are permitted provided that the following conditions are met: 509 * Redistributions of source code must retain the above copyright 510 notice, this list of conditions and the following disclaimer. 511 * Redistributions in binary form must reproduce the above copyright 512 notice, this list of conditions and the following disclaimer in the 513 documentation and/or other materials provided with the distribution. 514 * Neither the name of Knut Reinert or the FU Berlin nor the names of 515 its contributors may be used to endorse or promote products derived 516 from this software without specific prior written permission. 518 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 519 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 520 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 521 ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE 522 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 523 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 524 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 525 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 526 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 527 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 530 stream << views::repeat_n('=', 80) << to_text(
"\n\\fB") <<
"Copyright information for " 531 << meta.app_name <<
":\n" << to_text(
"\\fP") <<
views::repeat_n(
'-', 80) <<
'\n';
533 if (!
empty(meta.long_copyright))
535 stream << to_text(
"\\fP") << meta.long_copyright <<
"\n";
537 else if (!
empty(meta.short_copyright))
539 stream << to_text(
"\\fP") << meta.app_name <<
" full copyright information not available. Displaying" 540 <<
" short copyright information instead:\n" << to_text(
"\\fP") << meta.short_copyright <<
"\n";
544 stream << to_text(
"\\fP") << meta.app_name <<
" copyright information not available.\n";
548 <<
"This program contains SeqAn code licensed under the following terms:\n" << to_text(
"\\fP")
#define SEQAN3_VERSION_MINOR
The minor version as MACRO.
Definition: version.hpp:22
Provides seqan3::debug_stream and related types.
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
Provides seqan3::views::repeat_n.
Definition: aligned_sequence_concept.hpp:36
#define SEQAN3_VERSION_PATCH
The patch version as MACRO.
Definition: version.hpp:24
#define SEQAN3_VERSION_MAJOR
The major version as MACRO.
Definition: version.hpp:20
Provides SeqAn version macros and global variables.
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:94