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{
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;
51 ~format_man() = default;
52
54 format_man(std::vector<std::string> const & names, bool const advanced = false) : base_type{names, advanced} {};
56
57private:
60 {
62
63 // Print .TH line.
64 std::cout << ".TH ";
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 << "\" \"";
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
147 {
148 // no footer
149 }
150
156 {
157 return "\\fB" + str + "\\fR";
158 }
159
162};
163
164} // namespace seqan3::detail
T begin(T... args)
The format that contains all helper functions needed in all formats for printing the interface descri...
Definition format_base.hpp:197
argument_parser_meta_data meta
Stores all meta information about the application.
Definition format_base.hpp:421
The format that prints the help page information formatted for a man page to std::cout.
Definition format_man.hpp:35
~format_man()=default
Defaulted.
format_man & operator=(format_man const &pf)=default
Defaulted.
format_man(std::vector< std::string > const &names, bool const advanced=false)
Initializes a format_help_base object.
Definition format_man.hpp:54
bool is_first_in_section
Needed for correct indentation and line breaks.
Definition format_man.hpp:161
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:139
std::string in_bold(std::string const &str)
Format string as in_bold.
Definition format_man.hpp:155
void print_section(std::string const &title)
Prints a section title in man page format to std::cout.
Definition format_man.hpp:89
format_man(format_man const &pf)=default
Defaulted.
void print_footer()
Prints a help page footer in man page format.
Definition format_man.hpp:146
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:119
format_man & operator=(format_man &&)=default
Defaulted.
friend base_type
Befriend the base class to give access to the private member functions.
Definition format_man.hpp:40
void print_header()
Prints a help page header in man page format to std::cout.
Definition format_man.hpp:59
void print_subsection(std::string const &title)
Prints a subsection title in man page format to std::cout.
Definition format_man.hpp:107
format_man(format_man &&)=default
Defaulted.
format_man()=default
Defaulted.
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:252
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:315
std::string date
The date that the application was last updated. Keep this updated, ! since it will tell your users th...
Definition auxiliary.hpp:301
std::string version
The version information MAJOR.MINOR.PATH (e.g. 3.1.3)
Definition auxiliary.hpp:291
std::string app_name
The application name that will be displayed on the help page.
Definition auxiliary.hpp:289
std::string short_description
A short description of the application (e.g. "A tool for mapping reads to the genome").
Definition auxiliary.hpp:293
unsigned man_page_section
The man page section info (type man man on the command line for more information).
Definition auxiliary.hpp:317
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