SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
format_man.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
21 namespace seqan3::detail
22 {
23 
35 class format_man : public format_help_base<format_man>
36 {
38  using base_type = format_help_base<format_man>;
39 
41  friend base_type;
42 
43 public:
47  format_man() = default;
48  format_man(format_man const & pf) = default;
49  format_man & operator=(format_man const & pf) = default;
50  format_man(format_man &&) = default;
51  format_man & operator=(format_man &&) = default;
52  ~format_man() = default;
53 
55  format_man(std::vector<std::string> const & names, bool const advanced = false) : base_type{names, advanced}
56  {};
58 
59 private:
61  void print_header()
62  {
64 
65  // Print .TH line.
66  std::cout << ".TH ";
67  std::transform(meta.app_name.begin(), meta.app_name.end(), out, [] (unsigned char c) { return std::toupper(c); });
68  std::cout << " " << std::to_string(meta.man_page_section) << " \"" << meta.date << "\" \"";
69  std::transform(meta.app_name.begin(), meta.app_name.end(), out, [] (unsigned char c) { return std::tolower(c); });
70  std::cout << " " << meta.version << "\" \"" << meta.man_page_title << "\"\n";
71 
72  // Print NAME section.
73  std::cout << ".SH NAME\n"
74  << meta.app_name << " \\- " << meta.short_description << std::endl;
75  }
76 
80  void print_section(std::string const & title)
81  {
83  std::cout << ".SH ";
84  std::transform(title.begin(), title.end(), out, [] (unsigned char c) { return std::toupper(c); });
85  std::cout << "\n";
86  is_first_in_section = true;
87  }
88 
92  void print_subsection(std::string const & title)
93  {
94  std::cout << ".SS " << title << "\n";
95  is_first_in_section = true;
96  }
97 
104  void print_line(std::string const & text, bool const line_is_paragraph)
105  {
106  if (!is_first_in_section && line_is_paragraph)
107  std::cout << ".sp\n";
108  else if (!is_first_in_section && !line_is_paragraph)
109  std::cout << ".br\n";
110 
111  std::cout << text << "\n";
112  is_first_in_section = false;
113  }
114 
124  void print_list_item(std::string const & term, std::string const & desc)
125  {
126  std::cout << ".TP\n"
127  << term << "\n"
128  << desc << "\n";
129  is_first_in_section = false;
130  }
131 
133  void print_footer()
134  {
135  // Print legal stuff
136  if ((!empty(meta.short_copyright)) || (!empty(meta.long_copyright)) || (!empty(meta.citation)))
137  {
138  std::cout << ".SH LEGAL\n";
139 
140  if (!empty(meta.short_copyright))
141  std::cout << "\\fB" << meta.app_name << " Copyright:\\fR " << meta.short_copyright << "\n.br\n";
142 
143  std::cout << "\\fBSeqAn Copyright:\\fR 2006-2015 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.\n.br\n";
144 
145  if (!empty(meta.citation))
146  std::cout << "\\fBIn your academic works please cite:\\fR " << meta.citation << "\n.br\n";
147 
148  if (!empty(meta.long_copyright))
149  std::cout << "For full copyright and/or warranty information see \\fB--copyright\\fR.\n";
150  }
151  }
152 
154  bool is_first_in_section{true};
155 };
156 
157 } // namespace seqan3
std::string
std::vector< std::string >
version.hpp
Provides SeqAn version macros and global variables.
iostream
terminal.hpp
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
std::cout
std::to_string
T to_string(T... args)
std::transform
T transform(T... args)
format_base.hpp
Provides the format_base struct containing all helper functions that are needed in all formats.
std::ostream_iterator
std::endl
T endl(T... args)
std::string::begin
T begin(T... args)
std::empty
T empty(T... args)
std::string::end
T end(T... args)