Sharg 1.2.1-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{
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;
47 ~format_man() = default;
48
51 update_notifications const version_updates,
52 bool const advanced = false) :
53 base_type{names, version_updates, advanced} {};
55
56private:
59 {
60 std::cout << ".TH ";
62 std::cout << ' ' << meta.man_page_section << " \"" << meta.date << "\" \"";
64 std::cout << ' ' << meta.version << "\" \"" << meta.man_page_title << "\"\n";
65
66 std::cout << ".SH NAME\n";
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';
80 }
81
85 void print_subsection(std::string const & title)
86 {
87 std::cout << ".SS " << title << '\n';
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
125 {
126 // no footer
127 }
128
134 {
135 return "\\fB" + str + "\\fR";
136 }
137
140};
141
142} // namespace sharg::detail
static void print_as_uppercase(std::string const &str)
Prints a string to std::cout converted to uppercase.
Definition format_base.hpp:301
static void print_as_lowercase(std::string const &str)
Prints a string to std::cout converted to lowercase.
Definition format_base.hpp:287
The format that contains all helper functions needed in all formats for printing the interface descri...
Definition format_base.hpp:319
parser_meta_data meta
Stores all meta information about the application.
Definition format_base.hpp:601
The format that prints the help page information formatted for a man page to std::cout.
Definition format_man.hpp:31
format_man(format_man const &pf)=default
Defaulted.
format_man & operator=(format_man const &pf)=default
Defaulted.
format_man(std::vector< std::string > const &names, update_notifications const version_updates, bool const advanced=false)
Defaulted.
Definition format_man.hpp:50
void print_footer()
Prints a help page footer in man page format.
Definition format_man.hpp:124
format_man & operator=(format_man &&)=default
Defaulted.
void print_section(std::string const &title)
Prints a section title in man page format to std::cout.
Definition format_man.hpp:74
void print_header()
Prints a help page header in man page format to std::cout.
Definition format_man.hpp:58
std::string in_bold(std::string const &str)
Format string as in_bold.
Definition format_man.hpp:133
void print_line(std::string const &text, bool const line_is_paragraph)
Prints a help page section in man page format to std::cout.
Definition format_man.hpp:97
bool is_first_in_section
Needed for correct indentation and line breaks.
Definition format_man.hpp:139
~format_man()=default
Defaulted.
friend base_type
Befriend the base class to give access to the private member functions.
Definition format_man.hpp:36
void print_list_item(std::string const &term, std::string const &desc)
Prints a help page list_item in man page format to std::cout.
Definition format_man.hpp:117
format_man()=default
Defaulted.
format_man(format_man &&)=default
Defaulted.
void print_subsection(std::string const &title)
Prints a subsection title in man page format to std::cout.
Definition format_man.hpp:85
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
std::string short_description
A short description of the application (e.g. "A tool for mapping reads to the genome").
Definition auxiliary.hpp:111
std::string app_name
The application name that will be displayed on the help page.
Definition auxiliary.hpp:105
std::string version
The version information MAJOR.MINOR.PATH (e.g. 3.1.3)
Definition auxiliary.hpp:108
std::string man_page_title
The title of your man page when exported by specifying "--export-help man" on the common line.
Definition auxiliary.hpp:141
std::string date
The date that the application was last updated. Keep this updated, ! since it will tell your users th...
Definition auxiliary.hpp:122
unsigned man_page_section
The man page section info (type man man on the command line for more information).
Definition auxiliary.hpp:144
Hide me