SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
format_man.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <iostream>
13
16#include <seqan3/version.hpp>
17
18namespace seqan3::detail
19{
20
34class format_man : public format_help_base<format_man>
35{
37 using base_type = format_help_base<format_man>;
38
40 friend base_type;
41
42public:
46 format_man() = default;
47 format_man(format_man const & pf) = default;
48 format_man & operator=(format_man const & pf) = default;
49 format_man(format_man &&) = default;
50 format_man & operator=(format_man &&) = default;
51 ~format_man() = default;
52
54 format_man(std::vector<std::string> const & names, bool const advanced = false) : base_type{names, advanced} {};
56
57private:
59 void print_header()
60 {
62
63 // Print .TH line.
64 std::cout << ".TH ";
65 std::transform(meta.app_name.begin(),
66 meta.app_name.end(),
67 out,
68 [](unsigned char c)
69 {
70 return std::toupper(c);
71 });
72 std::cout << " " << std::to_string(meta.man_page_section) << " \"" << meta.date << "\" \"";
73 std::transform(meta.app_name.begin(),
74 meta.app_name.end(),
75 out,
76 [](unsigned char c)
77 {
78 return std::tolower(c);
79 });
80 std::cout << " " << meta.version << "\" \"" << meta.man_page_title << "\"\n";
81
82 // Print NAME section.
83 std::cout << ".SH NAME\n" << meta.app_name << " \\- " << meta.short_description << std::endl;
84 }
85
89 void print_section(std::string const & title)
90 {
92 std::cout << ".SH ";
93 std::transform(title.begin(),
94 title.end(),
95 out,
96 [](unsigned char c)
97 {
98 return std::toupper(c);
99 });
100 std::cout << "\n";
101 is_first_in_section = true;
102 }
103
107 void print_subsection(std::string const & title)
108 {
109 std::cout << ".SS " << title << "\n";
110 is_first_in_section = true;
111 }
112
119 void print_line(std::string const & text, bool const line_is_paragraph)
120 {
121 if (!is_first_in_section && line_is_paragraph)
122 std::cout << ".sp\n";
123 else if (!is_first_in_section && !line_is_paragraph)
124 std::cout << ".br\n";
125
126 std::cout << text << "\n";
127 is_first_in_section = false;
128 }
129
139 void print_list_item(std::string const & term, std::string const & desc)
140 {
141 std::cout << ".TP\n" << term << "\n" << desc << "\n";
142 is_first_in_section = false;
143 }
144
146 void print_footer()
147 {
148 // no footer
149 }
150
155 std::string in_bold(std::string const & str)
156 {
157 return "\\fB" + str + "\\fR";
158 }
159
161 bool is_first_in_section{true};
162};
163
164} // namespace seqan3::detail
T begin(T... args)
T end(T... args)
T endl(T... args)
Provides the format_base struct containing all helper functions that are needed in all formats.
@ advanced
Definition auxiliary.hpp:254
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
T to_string(T... args)
T transform(T... args)
Provides SeqAn version macros and global variables.
Hide me