fix: CLI11 integration

* Run 'sparkd tests' outside of the CLI::App framework
  (delegate to 'catch', which has a solid cli).  This
  fixes a bug which prevented callers from specifying
  test tags (in the form of '[<tag>]'), as the CLI::App's
  parse method removes square brackets from cli options.

* Bind cli options to instance members of their subcommand's
  CLI::App derived class.  This seems to fix a bug which caused
  the [static instance] binding source to be destructed twice.

 * Add help text for several subcommands
This commit is contained in:
John Colvin committed 2021-01-16 00:01:15 -06:00
1 parent 45de55a552
commit ca4e477f56
61 files changed
+841 -742

No files matched your search

+14 -11
View File
@@ -3,19 +3,22 @@
namespace bts::cmds {
static std::vector<std::string> args;
struct ConfigCheck::Args {
std::vector<std::string> args;
};
static void execute() {
std::vector<const char *> ch_args;
for (auto const &s : args)
ch_args.push_back(s.c_str());
configcheck(ch_args.size(), &ch_args[0]);
ConfigCheck::ConfigCheck()
: CLI::App("Print current configuration", "config-check"),
_args(new ConfigCheck::Args()) {
add_option("args", _args->args);
callback([&] {
std::vector<const char *> ch_args;
for (auto const &s : _args->args)
ch_args.push_back(s.c_str());
configcheck(ch_args.size(), &ch_args[0]);
});
}
void ConfigCheck::register_cmd(CLI::App &app) {
auto *cmd = app.add_subcommand("config-check");
cmd->add_option("args", args);
cmd->callback(execute);
}
ConfigCheck::~ConfigCheck() {}
} // namespace bts::cmds