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

libbitcoin / libbitcoin-explorer / 41710297289

03 Nov 2026 08:10PM UTC coverage: 98.845% (+10.6%) from 88.22%
41710297289

push

github

web-flow
Merge pull request #803 from evoskuil/master

Disable inlining in coverage builds.

7528 of 7616 relevant lines covered (98.84%)

24.29 hits per line

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

94.29
/src/parser.cpp
1
/**
2
 * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
3
 *
4
 * This file is part of libbitcoin.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
#include <bitcoin/explorer/parser.hpp>
20

21
#include <bitcoin/explorer/command.hpp>
22
#include <bitcoin/explorer/define.hpp>
23
#include <bitcoin/system.hpp>
24

25
using namespace bc::system;
26
using namespace bc::system::options;
27

28
namespace libbitcoin {
29
namespace explorer {
30

31
parser::parser(command& instance)
239 ✔
32
  : help_(false), instance_(instance)
239 ✔
33
{
34
}
239 ✔
35

36
bool parser::help() const
237 ✔
37
{
38
    return help_;
237 ✔
39
}
40

41
options_metadata parser::load_options()
239 ✔
42
{
43
    return instance_.load_options();
239 ✔
44
}
45

46
arguments_metadata parser::load_arguments()
239 ✔
47
{
48
    return instance_.load_arguments();
239 ✔
49
}
50

51
options_metadata parser::load_settings()
119 ✔
52
{
53
    options_metadata settings("settings");
119 ✔
54
    instance_.load_settings(settings);
119 ✔
55
    return settings;
119 ✔
56
}
×
57

58
options_metadata parser::load_environment()
119 ✔
59
{
60
    options_metadata environment("environment");
119 ✔
61
    instance_.load_environment(environment);
119 ✔
62
    return environment;
119 ✔
63
}
×
64

65
void parser::load_command_variables(std::istream& input, int argc,
239 ✔
66
    const char* argv[])
67
{
68
    system::options::parser::load_command_variables(argc, argv);
239 ✔
69

70
    // Don't load rest if help is specified.
71
    // For variable with stdin or file fallback load the input stream.
72
    if (!get_option(BX_HELP_VARIABLE))
237 ✔
73
        instance_.load_fallbacks(input, variables_);
119 ✔
74
}
237 ✔
75

76
bool parser::parse(std::string& out_error, std::istream& input,
239 ✔
77
    int argc, const char* argv[])
78
{
79
    try
80
    {
81
        // Must store before environment in order for commands to supercede.
82
        load_command_variables(input, argc, argv);
239 ✔
83

84
        // Don't load rest if help is specified.
85
        if (!get_option(BX_HELP_VARIABLE))
237 ✔
86
        {
87
            // Must store before configuration in order to specify the path.
88
            load_environment_variables(BX_ENVIRONMENT_VARIABLE_PREFIX);
119 ✔
89

90
            // Is lowest priority, which will cause confusion if there is
91
            // composition between them, which therefore should be avoided.
92
            /* auto file = */ load_configuration_variables(BX_CONFIG_VARIABLE);
119 ✔
93

94
            // Set variable defaults, send notifications and update bound vars.
95
            notify(variables_);
119 ✔
96

97
            // Set the instance defaults from config values.
98
            instance_.set_defaults_from_config(variables_);
119 ✔
99
        }
100
        else
101
        {
102
            help_ = true;
118 ✔
103
        }
104
    }
105
    catch (const option_exception& e)
2 ✔
106
    {
107
        out_error = e.what();
2 ✔
108
        return false;
109
    }
2 ✔
110

111
    return true;
112
}
113

114
} // namespace explorer
115
} // namespace libbitcoin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc