| 633 | } |
| 634 | |
| 635 | void 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 | |
| 659 | void ArgsManager::AddArg(const std::string& name, const std::string& help, unsigned int flags, const OptionsCategory& cat) |
| 660 | { |