Branch data Line data Source code
1 : : #pragma once
2 : :
3 : : #include <hpactor/cli/output_formatter.hpp>
4 : :
5 : : namespace hpactor {
6 : : namespace cli {
7 : :
8 : : class PrettyFormatter : public OutputFormatter {
9 : : public:
10 : : void header(const std::string& title) override;
11 : : void table(const std::vector<std::string>& columns,
12 : : const std::vector<std::vector<std::string>>& rows) override;
13 : : void key_value(const std::map<std::string, std::string>& pairs) override;
14 : : void tree(const TreeNode& root) override;
15 : : void raw(const std::string& text) override;
16 : : void error(const std::string& message) override;
17 : : std::string finalize() override;
18 : :
19 : : private:
20 : : std::string buffer_;
21 : : int columns_ = 80;
22 : :
23 : 5 : static std::string dim(const std::string& s) { return "\033[2m" + s + "\033[0m"; }
24 : 5 : static std::string bold(const std::string& s) { return "\033[1m" + s + "\033[0m"; }
25 : 4 : static std::string cyan(const std::string& s) { return "\033[36m" + s + "\033[0m"; }
26 : 4 : static std::string green(const std::string& s) { return "\033[32m" + s + "\033[0m"; }
27 : 1 : static std::string red(const std::string& s) { return "\033[31m" + s + "\033[0m"; }
28 : :
29 : : static std::string pad_right(const std::string& s, size_t width);
30 : : static std::string horizontal_rule(size_t width);
31 : : };
32 : :
33 : : } // namespace cli
34 : : } // namespace hpactor
|