Sharg 1.2.3-rc.1
The argument parser for bio-c++ tools.
Loading...
Searching...
No Matches
format_man.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2026, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2026, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
13
14namespace sharg::detail
15{
16
30class format_man : public format_help_base<format_man>
31{
33 using base_type = format_help_base<format_man>;
34
36 friend base_type;
37
38public:
42 format_man() = default;
43 format_man(format_man const & pf) = default;
44 format_man & operator=(format_man const & pf) = default;
45 format_man(format_man &&) = default;
46 format_man & operator=(format_man &&) = default;
47 ~format_man() = default;
48
50 format_man(std::vector<std::string> const & names,
51 update_notifications const version_updates,
52 bool const advanced = false) :
53 base_type{names, version_updates, advanced} {};
55
56private:
58 void print_header()
59 {
60 std::cout << ".TH ";
61 print_as_uppercase(meta.app_name);
62 std::cout << ' ' << meta.man_page_section << " \"" << meta.date << "\" \"";
63 print_as_lowercase(meta.app_name);
64 std::cout << ' ' << meta.version << "\" \"" << meta.man_page_title << "\"\n";
65
66 std::cout << ".SH NAME\n";
67 print_as_lowercase(meta.app_name);
68 std::cout << " \\- " << meta.short_description << '\n';
69 }
70
74 void print_section(std::string const & title)
75 {
76 std::cout << ".SH ";
77 print_as_uppercase(title);
78 std::cout << '\n';
79 is_first_in_section = true;
80 }
81
85 void print_subsection(std::string const & title)
86 {
87 std::cout << ".SS " << title << '\n';
88 is_first_in_section = true;
89 }
90
97 void print_line(std::string const & text, bool const line_is_paragraph)
98 {
99 if (!is_first_in_section && line_is_paragraph)
100 std::cout << ".sp\n";
101 else if (!is_first_in_section && !line_is_paragraph)
102 std::cout << ".br\n";
103
104 std::cout << text << '\n';
105 is_first_in_section = false;
106 }
107
117 void print_list_item(std::string const & term, std::string const & desc)
118 {
119 std::cout << ".TP\n" << term << '\n' << desc << '\n';
120 is_first_in_section = false;
121 }
122
124 void print_footer()
125 {
126 // no footer
127 }
128
133 std::string in_bold(std::string const & str)
134 {
135 return "\\fB" + str + "\\fR";
136 }
137
139 bool is_first_in_section{true};
140};
141
142} // namespace sharg::detail
Provides the format_base struct containing all helper functions that are needed in all formats.
update_notifications
Indicates whether application allows automatic update notifications by the sharg::parser.
Definition auxiliary.hpp:27
Hide me