Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Bring back --config to tst-tunnel argument parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Nov 17, 2019
1 parent 076d8e4 commit 0e65846
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tst-tunnel/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include env/target.mk

version := 0.9

args := ../app-shared/assets/default.cfg
args := --config ../app-shared/assets/default.cfg

.PHONY: all
all: $(output)/$(default)/orchid$(exe)
Expand Down
30 changes: 26 additions & 4 deletions tst-tunnel/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

#include <boost/program_options/parsers.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>

#include <asio.hpp>
#include "capture.hpp"
Expand All @@ -67,17 +68,38 @@

namespace orc {

namespace po = boost::program_options;

std::string Group() {
// UGH: error: 'current_path' is unavailable: introduced in macOS 10.15
//return std::filesystem::current_path();
return boost::filesystem::current_path().string();
}

int Main(int argc, const char *const argv[]) {
Initialize();
po::variables_map args;

po::options_description options("command-line (only)");
options.add_options()
("help", "produce help message")
("config", po::value<std::string>(), "configuration file for client configuration")
;

po::store(po::parse_command_line(argc, argv, po::options_description()
.add(options)
), args);

orc_assert(argc == 2);
const char *config(argv[1]);
po::notify(args);

if (args.count("help") != 0) {
std::cout << po::options_description()
.add(options)
<< std::endl;
return 0;
}


Initialize();


auto local(Host_);
Expand Down Expand Up @@ -117,7 +139,7 @@ int Main(int argc, const char *const argv[]) {

Wait([&]() -> task<void> { try {
co_await Schedule();
co_await capture->Start(config);
co_await capture->Start(args["config"].as<std::string>());
sync->Open();
} catch (const std::exception &error) {
std::cerr << error.what() << std::endl;
Expand Down

0 comments on commit 0e65846

Please sign in to comment.