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:
1 parent
45de55a552
commit
ca4e477f56
61 files changed
+841
-742
No files matched your search
+26
-17
@@ -1,3 +1,4 @@
|
||||
#include "lib/testing/catch_test_runner.h"
|
||||
#include "lib/utils/init_spark_lib.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
#include <CLI11/CLI11.hpp>
|
||||
@@ -17,7 +18,6 @@
|
||||
#include "server/sparkd/cmds/Run.h"
|
||||
#include "server/sparkd/cmds/Span.h"
|
||||
#include "server/sparkd/cmds/Spartan.h"
|
||||
#include "server/sparkd/cmds/Test.h"
|
||||
#include "server/sparkd/cmds/Web.h"
|
||||
|
||||
using namespace bts;
|
||||
@@ -25,24 +25,33 @@ using namespace bts;
|
||||
int main(int argc, char **argv) {
|
||||
utils::init_spark_lib();
|
||||
|
||||
// The 'test' cli is delegated to the catch lib/framework.
|
||||
if (argc > 1 && strcmp(argv[1], "test") == 0) {
|
||||
std::vector<std::string> v;
|
||||
for (int i = 2; i < argc; i++)
|
||||
v.emplace_back(argv[i]);
|
||||
return run_tests(v);
|
||||
}
|
||||
|
||||
CLI::App app("Futures trading system", "sparkd");
|
||||
app.require_subcommand();
|
||||
// register subcommands
|
||||
bts::cmds::AdminReport::register_cmd(app);
|
||||
bts::cmds::AutoCert::register_cmd(app);
|
||||
bts::cmds::Benchmark::register_cmd(app);
|
||||
bts::cmds::ConfigCheck::register_cmd(app);
|
||||
bts::cmds::FIXSim::register_cmd(app);
|
||||
bts::cmds::KeyCode::register_cmd(app);
|
||||
bts::cmds::Md::register_cmd(app);
|
||||
bts::cmds::ParseHistoricalFix::register_cmd(app);
|
||||
bts::cmds::PrintHedgeOrders::register_cmd(app);
|
||||
bts::cmds::QuickTest::register_cmd(app);
|
||||
bts::cmds::Run::register_cmd(app);
|
||||
bts::cmds::Span::register_cmd(app);
|
||||
bts::cmds::Spartan::register_cmd(app);
|
||||
bts::cmds::Test::register_cmd(app);
|
||||
bts::cmds::Web::register_cmd(app);
|
||||
// subcommands
|
||||
app.add_subcommand(CLI::App_p(new cmds::AdminReport()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::AutoCert()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Benchmark()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::ConfigCheck()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::FIXSim()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Md()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::ParseHistoricalFix()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::PrintHedgeOrders()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::QuickTest()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Run()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Span()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Spartan()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Web()));
|
||||
// Add a 'test' dummy subcommand, so it will be listed in the cli when the
|
||||
// user runs 'sparkd --help'.
|
||||
app.add_subcommand("test", "Run unit test(s)");
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
utils::finit_spark_lib();
|
||||
|
||||
Reference in new issue
Block a user