SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
format_man.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <iostream>
16
19#include <seqan3/version.hpp>
20
21namespace seqan3::detail
22{
23
37class format_man : public format_help_base<format_man>
38{
40 using base_type = format_help_base<format_man>;
41
43 friend base_type;
44
45public:
49 format_man() = default;
50 format_man(format_man const & pf) = default;
51 format_man & operator=(format_man const & pf) = default;
52 format_man(format_man &&) = default;
53 format_man & operator=(format_man &&) = default;
54 ~format_man() = default;
55
57 format_man(std::vector<std::string> const & names, bool const advanced = false) : base_type{names, advanced}
58 {};
60
61private:
63 void print_header()
64 {
66
67 // Print .TH line.
68 std::cout << ".TH ";
69 std::transform(meta.app_name.begin(), meta.app_name.end(), out, [] (unsigned char c) { return std::toupper(c); });
70 std::cout << " " << std::to_string(meta.man_page_section) << " \"" << meta.date << "\" \"";
71 std::transform(meta.app_name.begin(), meta.app_name.end(), out, [] (unsigned char c) { return std::tolower(c); });
72 std::cout << " " << meta.version << "\" \"" << meta.man_page_title << "\"\n";
73
74 // Print NAME section.
75 std::cout << ".SH NAME\n"
76 << meta.app_name << " \\- " << meta.short_description << std::endl;
77 }
78
82 void print_section(std::string const & title)
83 {
85 std::cout << ".SH ";
86 std::transform(title.begin(), title.end(), out, [] (unsigned char c) { return std::toupper(c); });
87 std::cout << "\n";
88 is_first_in_section = true;
89 }
90
94 void print_subsection(std::string const & title)
95 {
96 std::cout << ".SS " << title << "\n";
97 is_first_in_section = true;
98 }
99
106 void print_line(std::string const & text, bool const line_is_paragraph)
107 {
108 if (!is_first_in_section && line_is_paragraph)
109 std::cout << ".sp\n";
110 else if (!is_first_in_section && !line_is_paragraph)
111 std::cout << ".br\n";
112
113 std::cout << text << "\n";
114 is_first_in_section = false;
115 }
116
126 void print_list_item(std::string const & term, std::string const & desc)
127 {
128 std::cout << ".TP\n"
129 << term << "\n"
130 << desc << "\n";
131 is_first_in_section = false;
132 }
133
135 void print_footer()
136 {
137 // no footer
138 }
139
144 std::string in_bold(std::string const & str)
145 {
146 return "\\fB" + str + "\\fR";
147 }
148
150 bool is_first_in_section{true};
151};
152
153} // namespace seqan3
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:256
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.