From 639e242693d2a501a7dec1e978aa00371d806e46 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Wed, 16 Feb 2022 13:29:47 -0400 Subject: [PATCH] Unknown cli parameters handling in cli_wallet --- programs/cli_wallet/main.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 34719fbd..d4e1d1ba 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #ifdef WIN32 # include @@ -89,7 +90,16 @@ int main( int argc, char** argv ) bpo::variables_map options; - bpo::store( bpo::parse_command_line(argc, argv, opts), options ); + bpo::parsed_options po = bpo::command_line_parser(argc, argv).options(opts).allow_unregistered().run(); + std::vector unrecognized = bpo::collect_unrecognized(po.options, bpo::include_positional); + if (unrecognized.size() > 0) { + std::cout << "Unknown parameter(s): " << std::endl; + for (auto s : unrecognized) { + std::cout << " " << s << std::endl; + } + return 0; + } + bpo::store( po, options ); if( options.count("help") ) { @@ -103,9 +113,9 @@ int main( int argc, char** argv ) const size_t pos = wallet_version.find('/'); if( pos != std::string::npos && wallet_version.size() > pos ) wallet_version = wallet_version.substr( pos + 1 ); - std::cerr << "Version: " << wallet_version << "\n"; - std::cerr << "Git Revision: " << graphene::utilities::git_revision_sha << "\n"; - std::cerr << "Built: " << __DATE__ " at " __TIME__ << "\n"; + std::cout << "Version: " << wallet_version << "\n"; + std::cout << "Git Revision: " << graphene::utilities::git_revision_sha << "\n"; + std::cout << "Built: " << __DATE__ " at " __TIME__ << "\n"; std::cout << "SSL: " << OPENSSL_VERSION_TEXT << "\n"; std::cout << "Boost: " << boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".") << "\n"; return 0;