Skip to content

Commit

Permalink
Fix --help and -? options
Browse files Browse the repository at this point in the history
Stop on invalid options
Fixes 52 and 53
  • Loading branch information
lclc committed Mar 29, 2021
1 parent a09d287 commit ccc0c4a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,28 @@ class CDnsSeedOpts {
{"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:a:p:d:o:i:k:w:", long_options, &option_index);
int c = getopt_long(argc, argv, "h:n:m:t:a:p:d:o:i:k:w:?", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h': {
host = optarg;
break;
}

case 'm': {
mbox = optarg;
break;
}

case 'n': {
ns = optarg;
break;
}

case 't': {
int n = strtol(optarg, NULL, 10);
if (n > 0 && n < 1000) nThreads = n;
Expand Down Expand Up @@ -174,7 +174,10 @@ class CDnsSeedOpts {
filter_whitelist.insert(NODE_NETWORK_LIMITED | NODE_WITNESS | NODE_BLOOM); // x40c
}
if (host != NULL && ns == NULL) showHelp = true;
if (showHelp) fprintf(stderr, help, argv[0]);
if (showHelp) {
fprintf(stderr, help, argv[0]);
exit(0);
}
}
};

Expand Down

0 comments on commit ccc0c4a

Please sign in to comment.