From: Kefu Chai Date: Tue, 16 Jul 2019 06:52:12 +0000 (+0800) Subject: tools/ceph_conf: use std::quoted() X-Git-Tag: v14.2.17~90^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03dc1206214c95bb679cca7930bfb5e8f7405b45;p=ceph.git tools/ceph_conf: use std::quoted() * use std::quoted() for better readability * use string literals to avoid escapings which are distrating. Signed-off-by: Kefu Chai (cherry picked from commit d4af6fea3ea51c12190062d81694c367f82ad31f) --- diff --git a/src/tools/ceph_conf.cc b/src/tools/ceph_conf.cc index 1835317d60f7..d4d003b7577a 100644 --- a/src/tools/ceph_conf.cc +++ b/src/tools/ceph_conf.cc @@ -12,6 +12,7 @@ * */ +#include #include #include "common/ceph_argparse.h" @@ -25,45 +26,45 @@ using std::string; static void usage() { // TODO: add generic_usage once cerr/derr issues are resolved - cerr << "Ceph configuration query tool\n\ -\n\ -USAGE\n\ -ceph-conf \n\ -\n\ -ACTIONS\n\ - -L|--list-all-sections List all sections\n\ - -l|--list-sections List sections with the given prefix\n\ - --filter-key Filter section list to only include sections\n\ - with given key defined.\n\ - --filter-key-value = Filter section list to only include sections\n\ - with given key/value pair.\n\ - --lookup Print a configuration setting to stdout.\n\ - Returns 0 (success) if the configuration setting is\n\ - found; 1 otherwise.\n\ - -r|--resolve-search search for the first file that exists and\n\ - can be opened in the resulted comma\n\ - delimited search list.\n\ - -D|--dump-all dump all variables.\n\ -\n\ -FLAGS\n\ - --name name Set type.id\n\ - [-s
] Add to list of sections to search\n\ - [--format plain|json|json-pretty]\n\ - dump variables in plain text, json or pretty\n\ - json\n\ -\n\ -If there is no action given, the action will default to --lookup.\n\ -\n\ -EXAMPLES\n\ -$ ceph-conf --name mon.0 -c /etc/ceph/ceph.conf 'mon addr'\n\ -Find out what the value of 'mon addr' is for monitor 0.\n\ -\n\ -$ ceph-conf -l mon\n\ -List sections beginning with 'mon'.\n\ -\n\ -RETURN CODE\n\ -Return code will be 0 on success; error code otherwise.\n\ -"; + out << R"(Ceph configuration query tool + +USAGE +ceph-conf + +ACTIONS + -L|--list-all-sections List all sections + -l|--list-sections List sections with the given prefix + --filter-key Filter section list to only include sections + with given key defined. + --filter-key-value = Filter section list to only include sections + with given key/value pair. + --lookup Print a configuration setting to stdout. + Returns 0 (success) if the configuration setting is + found; 1 otherwise. + -r|--resolve-search search for the first file that exists and + can be opened in the resulted comma + delimited search list. + -D|--dump-all dump all variables. + +FLAGS + --name name Set type.id + [-s
] Add to list of sections to search + [--format plain|json|json-pretty] + dump variables in plain text, json or pretty + json + +If there is no action given, the action will default to --lookup. + +EXAMPLES +$ ceph-conf --name mon.0 -c /etc/ceph/ceph.conf 'mon addr' +Find out what the value of 'mon addr' is for monitor 0. + +$ ceph-conf -l mon +List sections beginning with 'mon'. + +RETURN CODE +Return code will be 0 on success; error code otherwise. +)"; } static int list_sections(const std::string &prefix, @@ -229,8 +230,8 @@ int main(int argc, const char **argv) } else { cerr << "unable to parse option: '" << *i << "'" << std::endl; cerr << "args:"; - for (std::vector::iterator ci = orig_args.begin(); ci != orig_args.end(); ++ci) { - cerr << " '" << *ci << "'"; + for (auto arg : orig_args) { + cerr << " " << quoted(arg); } cerr << std::endl; usage();