MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / AddCommand

Method AddCommand

src/common/args.cpp:635–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635void ArgsManager::AddCommand(const std::string& cmd, const std::string& help, std::set<std::string> options)
636{
637 Assert(cmd.find('=') == std::string::npos);
638 Assert(cmd.at(0) != '-');
639
640 LOCK(cs_args);
641 m_accept_any_command = false; // latch to false
642 std::map<std::string, Arg>& arg_map = m_available_args[OptionsCategory::COMMANDS];
643 auto ret = arg_map.emplace(cmd, Arg{"", help, ArgsManager::COMMAND});
644 if (!options.empty()) {
645 auto& cmdopts = m_available_args[OptionsCategory::COMMAND_OPTIONS];
646 bool command_has_all_options_defined = true;
647 for (const auto& opt : options) {
648 if (!cmdopts.contains(opt)) {
649 command_has_all_options_defined = false;
650 }
651 }
652 Assert(command_has_all_options_defined);
653
654 m_command_args.try_emplace(cmd, std::move(options));
655 }
656 Assert(ret.second); // Fail on duplicate commands
657}
658
659void ArgsManager::AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat)
660{

Callers 4

SetupBitcoinUtilArgsFunction · 0.80
SetupWalletToolArgsFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
system.cppFile · 0.80

Calls 5

findMethod · 0.80
emplaceMethod · 0.80
atMethod · 0.45
emptyMethod · 0.45
containsMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64