From 7ba15f91f3eb12e58add1bb512a67fe4f31d4475 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 18 May 2021 16:38:09 -0400 Subject: [PATCH 1/2] add --help and -h flags to lokinet-bootstrap to show help message --- daemon/lokinet-bootstrap.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/daemon/lokinet-bootstrap.cpp b/daemon/lokinet-bootstrap.cpp index 7e8a4305a..12feac244 100644 --- a/daemon/lokinet-bootstrap.cpp +++ b/daemon/lokinet-bootstrap.cpp @@ -9,6 +9,7 @@ #include #include +#include #ifndef _WIN32 #include @@ -28,6 +29,24 @@ namespace std::cout << msg << std::endl; return 1; } + + int + print_help(std::string exe) + { + std::cout << R"(Lokinet bootstrap.signed fetchy program thing + +Downloads the initial bootstrap.signed for lokinet into a local file from a default or user defined server via the reachable network. + +Usage: )" << exe + << R"( [bootstrap_url [output_file]] + +bootstrap_url can be a named value in which we will use a predefined url that +holds a bootstrap file + +)"; + return 0; + } + } // namespace int @@ -42,6 +61,15 @@ main(int argc, char* argv[]) std::string bootstrap_url = bootstrap_urls.at("lokinet"); fs::path outputfile{llarp::GetDefaultBootstrap()}; + const std::unordered_set help_args = {"-h", "--help"}; + + for (int idx = 1; idx < argc; idx++) + { + const std::string arg{argv[idx]}; + if (help_args.count(arg)) + return print_help(argv[0]); + } + if (argc > 1) { if (auto itr = bootstrap_urls.find(argv[1]); itr != bootstrap_urls.end()) @@ -57,7 +85,7 @@ main(int argc, char* argv[]) { outputfile = fs::path{argv[2]}; } - + std::cout << "fetching " << bootstrap_url << std::endl; cpr::Response resp = #ifdef _WIN32 cpr::Get( @@ -79,6 +107,7 @@ main(int argc, char* argv[]) { try { + std::cout << "writing bootstrap file to: " << outputfile << std::endl; fs::ofstream ofs{outputfile, std::ios::binary}; ofs.exceptions(fs::ofstream::failbit); ofs << data; From 6c3c52340436254ad7cfbc5101089a127a26a6d4 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Wed, 8 Sep 2021 19:48:25 -0300 Subject: [PATCH 2/2] Update wording and wrap help message --- daemon/lokinet-bootstrap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon/lokinet-bootstrap.cpp b/daemon/lokinet-bootstrap.cpp index 12feac244..435ec6767 100644 --- a/daemon/lokinet-bootstrap.cpp +++ b/daemon/lokinet-bootstrap.cpp @@ -35,13 +35,15 @@ namespace { std::cout << R"(Lokinet bootstrap.signed fetchy program thing -Downloads the initial bootstrap.signed for lokinet into a local file from a default or user defined server via the reachable network. +Downloads the initial bootstrap.signed for lokinet into a local file from a +default or user defined server via the reachable network. Usage: )" << exe << R"( [bootstrap_url [output_file]] -bootstrap_url can be a named value in which we will use a predefined url that -holds a bootstrap file +bootstrap_url can be specified as a full URL, or a special named value +("mainnet" or "testnet") to download from the pre-defined mainnet or testnet +bootstrap URLs. )"; return 0;