From 3d9787e003e7c96c734fd0d625c465974412a7b8 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Wed, 26 Nov 2014 01:48:46 +0600 Subject: [PATCH] fix some CL arguments handling --- main.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 51eacd5..88e9675 100644 --- a/main.cpp +++ b/main.cpp @@ -31,7 +31,7 @@ public: CDnsSeedOpts() : nThreads(96), nDnsThreads(4), nPort(53), mbox(NULL), ns(NULL), host(NULL), tor(NULL), fUseTestNet(false), fWipeBan(false), fWipeIgnore(false) {} void ParseCommandLine(int argc, char **argv) { - static const char *help = "Bitcoin-seeder\n" + static const char *help = "Twister-seeder\n" "Usage: %s -h -n [-m ] [-t ] [-p ]\n" "\n" "Options:\n" @@ -61,11 +61,11 @@ public: {"testnet", no_argument, &fUseTestNet, 1}, {"wipeban", no_argument, &fWipeBan, 1}, {"wipeignore", no_argument, &fWipeBan, 1}, - {"help", no_argument, 0, 'h'}, + {"help", no_argument, 0, '?'}, {0, 0, 0, 0} }; int option_index = 0; - int c = getopt_long(argc, argv, "h:n:m:t:p:d:o:", long_options, &option_index); + int c = getopt_long(argc, argv, "h:n:m:t:d:p:o:?", long_options, &option_index); if (c == -1) break; switch (c) { case 'h': { @@ -112,8 +112,15 @@ public: } } } - if (host != NULL && ns == NULL) showHelp = true; - if (showHelp) fprintf(stderr, help, argv[0]); + + if (host == NULL || ns == NULL) { + fprintf(stderr, "Wanna dance? RTFM, babe!\n\n"); + showHelp = true; + } + if (showHelp) { + fprintf(stderr, help, argv[0]); + exit(EXIT_SUCCESS); + } } };