From adec10db28a123bc0d64f8d1ff70b51b5ea5c435 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 18 Nov 2020 12:19:27 +0100 Subject: [PATCH] bin: consolidate clients --- src/bin/common/options.cpp | 24 +- src/bin/common/options.hpp | 7 +- src/bin/memstat.cc | 527 ++++++++++++++---------------------- test/tests/bin/memerror.cpp | 2 - test/tests/bin/memstat.cpp | 17 +- 5 files changed, 226 insertions(+), 351 deletions(-) diff --git a/src/bin/common/options.cpp b/src/bin/common/options.cpp index 229f4f0f..8c520b8f 100644 --- a/src/bin/common/options.cpp +++ b/src/bin/common/options.cpp @@ -14,13 +14,6 @@ */ #include "options.hpp" -#include - -option client_options::null_opt{}; -const client_options::extended_option client_options::null_ext_opt{ - client_options::null_opt, - {}, {}, {},nullptr, false -}; void client_options::print_version() const { std::cout << prog_name << " v" << prog_vers << " (libmemcached v" << LIBMEMCACHED_VERSION_STRING << ")" @@ -84,8 +77,7 @@ void client_options::print_help() const { std::cout << "\n\t\t" << ext.help << "\n"; } - const auto &servers = get("servers"); - if (&servers != &null_ext_opt) { + if (has("servers")) { std::cout << "\nEnvironment:\n"; std::cout << "\tMEMCACHED_SERVERS=\n"; std::cout << "\t\tList of servers to use if `-s|--servers` was not provided.\n"; @@ -95,7 +87,7 @@ void client_options::print_help() const { bool client_options::parse(int argc, char **argv, char ***argp) { /* extern */ optind = 1; - auto &debug = get("debug"); + auto debug = has("debug") ? &get("debug") : nullptr; std::string short_opts{}; std::vector