Loading...
Searching...
No Matches
format_man.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <iostream>
#include <seqan3/argument_parser/detail/format_base.hpp>
#include <seqan3/argument_parser/detail/terminal.hpp>
#include <seqan3/version.hpp>
namespace seqan3::detail
{
class format_man : public format_help_base<format_man>
{
using base_type = format_help_base<format_man>;
friend base_type;
public:
format_man() = default;
format_man(format_man const & pf) = default;
format_man & operator=(format_man const & pf) = default;
format_man(format_man &&) = default;
format_man & operator=(format_man &&) = default;
~format_man() = default;
format_man(std::vector<std::string> const & names, bool const advanced = false) : base_type{names, advanced} {};
private:
void print_header()
{
std::ostream_iterator<char> out(std::cout);
// Print .TH line.
std::cout << ".TH ";
std::transform(meta.app_name.begin(),
meta.app_name.end(),
out,
[](unsigned char c)
{
return std::toupper(c);
});
std::cout << " " << std::to_string(meta.man_page_section) << " \"" << meta.date << "\" \"";
std::transform(meta.app_name.begin(),
meta.app_name.end(),
out,
[](unsigned char c)
{
return std::tolower(c);
});
std::cout << " " << meta.version << "\" \"" << meta.man_page_title << "\"\n";
// Print NAME section.
std::cout << ".SH NAME\n" << meta.app_name << " \\- " << meta.short_description << std::endl;
}
void print_section(std::string const & title)
{
std::ostream_iterator<char> out(std::cout);
std::cout << ".SH ";
std::transform(title.begin(),
title.end(),
out,
[](unsigned char c)
{
return std::toupper(c);
});
std::cout << "\n";
is_first_in_section = true;
}
void print_subsection(std::string const & title)
{
std::cout << ".SS " << title << "\n";
is_first_in_section = true;
}
void print_line(std::string const & text, bool const line_is_paragraph)
{
if (!is_first_in_section && line_is_paragraph)
std::cout << ".sp\n";
else if (!is_first_in_section && !line_is_paragraph)
std::cout << ".br\n";
std::cout << text << "\n";
is_first_in_section = false;
}
void print_list_item(std::string const & term, std::string const & desc)
{
std::cout << ".TP\n" << term << "\n" << desc << "\n";
is_first_in_section = false;
}
void print_footer()
{
// no footer
}
std::string in_bold(std::string const & str)
{
return "\\fB" + str + "\\fR";
}
bool is_first_in_section{true};
};
} // namespace seqan3::detail
std::string::begin
T begin(T... args)
std::string::end
T end(T... args)
std::endl
T endl(T... args)
format_base.hpp
Provides the format_base struct containing all helper functions that are needed in all formats.
seqan3::advanced
@ advanced
Definition auxiliary.hpp:256
iostream
terminal.hpp
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
std::to_string
T to_string(T... args)
std::transform
T transform(T... args)
version.hpp
Provides SeqAn version macros and global variables.
Hide me