koutil
Loading...
Searching...
No Matches
help.h
Go to the documentation of this file.
1#ifndef KOUTIL_ARGS_HELP_H
2#define KOUTIL_ARGS_HELP_H
3
8#include <cstddef>
9#include <ostream>
10#include <string_view>
11#include <vector>
12
13namespace koutil::args {
14
15template <extends_result> class command_t;
16
17template <extends_result Result> class help_printer_t {
18public:
19 using result_t = Result;
23
24 help_printer_t(const command_t& cmd, std::size_t terminal_size = 80)
25 : m_cmd(cmd)
26 , m_term_size(terminal_size) { }
27
28 void print(std::ostream& out);
29
30private:
32 std::size_t m_term_size;
33
34 void print_arguments(std::ostream& out, const std::vector<argument_t>& args);
35 void print_options(std::ostream& out, const std::vector<option_t>& options);
36 void print_commands(std::ostream& out, const std::vector<command_t>& cmds);
37
38 void print_item(
39 std::ostream& out,
40 std::size_t max_size,
41 std::string_view prefix,
42 std::string_view name,
43 std::string_view description
44 );
45};
46
47}
48
49#endif
Represents a command in the command-line interface.
Definition help.h:15
Definition help.h:17
help_printer_t(const command_t &cmd, std::size_t terminal_size=80)
Definition help.h:24
void print_options(std::ostream &out, const std::vector< option_t > &options)
Definition help_impl.h:74
argument_t< result_t > argument_t
Definition help.h:22
Result result_t
Definition help.h:19
void print_item(std::ostream &out, std::size_t max_size, std::string_view prefix, std::string_view name, std::string_view description)
Definition help_impl.h:162
void print_arguments(std::ostream &out, const std::vector< argument_t > &args)
Definition help_impl.h:55
const command_t & m_cmd
Definition help.h:31
void print(std::ostream &out)
Definition help_impl.h:19
void print_commands(std::ostream &out, const std::vector< command_t > &cmds)
Definition help_impl.h:143
std::size_t m_term_size
Definition help.h:32
option_t< result_t > option_t
Definition help.h:21
Definition argument.h:9