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

+30 -30
View File
@@ -22,45 +22,45 @@
namespace bts::cmds {
struct Args {
struct Web::Args {
bool md;
};
static Args args;
Web::Web()
: CLI::App(
"Run only the services required for the web admin. This cannot be "
"run concurrently with 'sparkd run.'",
"web"),
_args(new Web::Args()) {
add_flag("--md", _args->md, "Start market data");
callback([&] {
config::QuickbusNodeCfg qb_cfg;
auto &ports = config::get<config::Ports>();
qb_cfg.set_my_port(ports.qbus_port());
qbus::Quickbus quickbus(qb_cfg);
api::ServiceContext sc(&quickbus);
static void execute() {
config::QuickbusNodeCfg qb_cfg;
auto &ports = config::get<config::Ports>();
qb_cfg.set_my_port(ports.qbus_port());
qbus::Quickbus quickbus(qb_cfg);
api::ServiceContext sc(&quickbus);
metrics::MetricsContainer stats;
metrics::publish_system_metrics(stats);
trace::PerfLog perf_log;
http::SparkWebServer webserver(sc, stats, perf_log, ports.config_port());
metrics::MetricsContainer stats;
metrics::publish_system_metrics(stats);
trace::PerfLog perf_log;
http::SparkWebServer webserver(sc, stats, perf_log, ports.config_port());
user::AuthServiceServer login_server(sc);
if (_args->md) {
md::run_market_datapublishers(nullptr, nullptr);
}
user::AuthServiceServer login_server(sc);
if (args.md) {
md::run_market_datapublishers(nullptr, nullptr);
}
api::synthetic::SyntheticSecurityService synthetic_service(sc);
md::MDClient mdclient(&utils::Dispatcher::current(), &synthetic_service);
md::QueryServerPtr md_query_server(
md::run_query_server(sc, mdclient, stats));
api::synthetic::SyntheticSecurityService synthetic_service(sc);
md::MDClient mdclient(&utils::Dispatcher::current(), &synthetic_service);
md::QueryServerPtr md_query_server(
md::run_query_server(sc, mdclient, stats));
admin::AdminServiceServer admin_service(sc);
admin::AdminServiceServer admin_service(sc);
utils::Dispatcher::current().run();
utils::Dispatcher::current().run();
});
}
void Web::register_cmd(CLI::App &app) {
auto *cmd = app.add_subcommand(
"web", "Run only the services required for the web admin. This cannot "
"be run concurrently with 'sparkd run.'");
cmd->add_flag("--md", args.md, "Start market data");
cmd->callback(execute);
}
Web::~Web() {}
} // namespace bts::cmds