Squashed 'libs/CommService/' content from commit 7ccc0fc
git-subtree-dir: libs/CommService git-subtree-split: 7ccc0fce88bbc5969df060058cf0fb57abe3bcf9
This commit is contained in:
49
libs/libbattle-com/bccli/main.cpp
Normal file
49
libs/libbattle-com/bccli/main.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <BC/BC.hpp>
|
||||
#include <testservice/testservice.hpp>
|
||||
#include <ping/ping.hpp>
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::string broadcastAddress="127.0.0.255";
|
||||
std::string srcAddress="127.0.0.1";
|
||||
unsigned short port = 8888;
|
||||
// which devices we want to reach, default all
|
||||
BC::DataTypes::deviceIdType destination = 0;
|
||||
|
||||
CLI::App app("Command line tool for interacting with libbattle-com++");
|
||||
app.require_subcommand(1);
|
||||
|
||||
// command line options for testservice command
|
||||
auto testservice = app.add_subcommand("testservice", "start a battle-com service but to not subscribe to anything.");
|
||||
testservice->add_option("-b",broadcastAddress,"the broadcast address to use for the pub/sub service (Default: 127.0.0.255)");
|
||||
testservice->add_option("-s",srcAddress,"the source address to use for the pub/sub service (Default: 127.0.0.1 )");
|
||||
testservice->add_option("-p",port,"the broadcast port to use for the pub/sub service (Default: 8888)");
|
||||
|
||||
testservice->callback( [&](){
|
||||
BCCLI::testservice(broadcastAddress, srcAddress, port);
|
||||
});
|
||||
|
||||
|
||||
// command line options for ping command
|
||||
auto ping = app.add_subcommand("ping", "ping another service and print round trip times");
|
||||
ping->add_option("-b",broadcastAddress,"the broadcast address to use for the pub/sub service (Default: 127.0.0.255)");
|
||||
ping->add_option("-s",srcAddress,"the source address to use for the pub/sub service (Default: 127.0.0.1 )");
|
||||
ping->add_option("-p",port,"the broadcast port to use for the pub/sub service (Default: 8888)");
|
||||
ping->add_option("-d",destination,"the destionation to ping (Default: allDevices)");
|
||||
|
||||
ping->callback( [&](){
|
||||
BCCLI::ping(broadcastAddress, srcAddress, port,destination);
|
||||
});
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user