• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbits-os / quick_dra / 22054814568

16 Feb 2026 08:08AM UTC coverage: 95.449% (+8.4%) from 87.008%
22054814568

Pull #39

github

web-flow
Merge c1ce10f54 into 7d773e4d9
Pull Request #39: testing

50 of 54 new or added lines in 22 files covered. (92.59%)

5 existing lines in 4 files now uncovered.

4195 of 4395 relevant lines covered (95.45%)

1613.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/libs/cli/src/builtins.cpp
1
// Copyright (c) 2026 midnightBITS
2
// This code is licensed under MIT license (see LICENSE for details)
3

4
#include "builtins.hpp"
5
#include <fmt/format.h>
6
#include <quick_dra/version.hpp>
7

8
namespace quick_dra::builtin {
9
        namespace {
10
                [[noreturn]] void show_version() {
4✔
11
                        fmt::print("{} version {}\n", version::program, version::ui);
10✔
12
                        std::exit(0);
10✔
13
                }
6✔
14
        }  // namespace
15

16
        void help_group::copy_to(args::chunk& chunk) const {
7✔
17
                chunk.title.assign(name);
19✔
18
                chunk.items.reserve(commands.size());
19✔
19
                for (auto [cmd_name, description] : commands)
40✔
20
                        chunk.items.push_back({as_str(cmd_name), as_str(description)});
22✔
21
        }
19✔
22

23
        void help_group::add_to_parser(args::parser& parser,
381✔
24
                                       std::span<help_group const> const& groups) {
1✔
25
                parser.provide_help(false);
1,144✔
26
                parser
763✔
27
                    .custom(
1,270✔
28
                        [command_groups = groups] [[noreturn]] (args::parser & p) {
7✔
29
                                help_group::show_help(p, command_groups);
19✔
30
                        },
13✔
31
                        "h", "help")
762✔
32
                    .help("shows this help message and exits"sv)
1,270✔
33
                    .opt();
1,143✔
34
        }
1,144✔
35

36
        void help_group::fill_help(args::fmt_list& commands,
6✔
37
                                   std::span<help_group const> const& groups) {
1✔
38
                commands.reserve(commands.size() + groups.size());
19✔
39
                for (auto const& group : groups) {
25✔
40
                        commands.emplace_back();
19✔
41
                        group.copy_to(commands.back());
19✔
42
                }
13✔
43
        }
19✔
44

45
        [[noreturn]] void help_group::show_help(
6✔
46
            args::parser& parser,
47
            std::span<help_group const> const& groups) {
1✔
48
                auto commands = parser.printer_arguments();
19✔
49
                fill_help(commands, groups);
19✔
50

12✔
51
                parser.short_help();
19✔
52
                args::printer{stdout}.format_list(commands);
19✔
53
                std::exit(0);
19✔
54
        }
12✔
55

56
        parser::parser(std::string_view description,
381✔
57
                       args::args_view const& args,
58
                       std::span<help_group const> const& groups,
59
                       bool is_root)
381✔
60
            : parser_{as_str(description), args, &tr_}, groups_{groups} {
382✔
61
                if (is_root) {
382✔
62
                        parser_.usage("[-h] [--version] <command> [<args>]"sv);
658✔
63
                } else {
439✔
64
                        parser_.usage("[-h] <command> [<args>]"sv);
487✔
65
                }
324✔
66
                builtin::help_group::add_to_parser(parser_, groups);
1,144✔
67
        }
1,144✔
68

69
        root_parser::root_parser(args::args_view const& args,
219✔
70
                                 std::span<help_group const> const& groups)
219✔
71
            : parser{""sv, args, groups, true} {
220✔
72
                get_parser()
658✔
73
                    .custom(show_version, "v", "version")
730✔
74
                    .help("show version and exit")
876✔
75
                    .opt();
730✔
76
        }
658✔
77

78
        options parser::parse_args() {
382✔
79
                auto const unparsed = parser_.parse(args::parser::allow_subcommands);
1,144✔
80
                if (unparsed.empty()) {
373✔
81
                        builtin::help_group::show_help(parser_, groups_);
×
82
                }
83

762✔
84
                auto const tool = unparsed[0];
1,135✔
85
                if (!tool.empty() && tool.front() == '-')
373✔
86
                        parser_.error(parser_.tr()(args::lng::unrecognized, tool));
87

762✔
88
                return {tool, unparsed.shift()};
1,507✔
89
        }
763✔
90

91
        void parser::noent(std::string_view tool, std::string_view my_name) const {
92
                args::fmt_list commands{};
×
93
                builtin::help_group::fill_help(commands, groups_);
×
UNCOV
94
                parser_.short_help(stderr);
×
95

96
                auto prn = args::printer{stderr};
×
97
                auto msg = fmt::format("\"{}\" is not a {} command", tool, my_name);
×
98
                prn.format_paragraph(fmt::format("{}: {}", parser_.program(), msg), 0);
×
99
                prn.format_list(commands);
×
100
        }
×
101
}  // namespace quick_dra::builtin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc