summaryrefslogtreecommitdiffstats
path: root/src/librados-config.cc
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2018-03-08 23:36:57 +0100
committerSage Weil <sage@redhat.com>2018-03-15 21:51:55 +0100
commit6972273d53dc2fcbe9c65d70a4e0f2af6270194e (patch)
tree418ef0c29a4d89bf91c31ad05cd2221e5fee1441 /src/librados-config.cc
parentMerge pull request #20769 from oritwas/wip-rgw-20448 (diff)
downloadceph-6972273d53dc2fcbe9c65d70a4e0f2af6270194e.tar.xz
ceph-6972273d53dc2fcbe9c65d70a4e0f2af6270194e.zip
global: output usage on -h, --help, or no args before contacting mons
- when there are no arguments, print a short invitation to stderr to use -h or --help and exit with an error. - if we get -h or --help, print usage to stdout, and exit with success. - do the above *before* making any contact with the cluster. we should not fail to explain usage because the mons are down. - if there is some other error with the arguments, print an error message, but do not spam the user with usage. Try to use cerr instead of derr. Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/librados-config.cc')
-rw-r--r--src/librados-config.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librados-config.cc b/src/librados-config.cc
index a7fb69ba13c..1dbb7a101f6 100644
--- a/src/librados-config.cc
+++ b/src/librados-config.cc
@@ -37,6 +37,13 @@ int main(int argc, const char **argv)
{
vector<const char*> args;
argv_to_vec(argc, argv, args);
+ if (args.empty()) {
+ cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ exit(1);
+ }
+ if (ceph_argparse_need_usage(args)) {
+ usage_exit();
+ }
bool opt_version = false;
bool opt_vernum = false;