Convert invocations of usage() to fatal()

The usage text is extremely long which causes the error message to
scroll off the top of the screen. Switch to fatal() to avoid this
problem.
This commit is contained in:
Richard Hansen 2020-05-28 13:37:38 -04:00
parent ca7f0927fc
commit 7be4d58b90

View file

@ -807,7 +807,10 @@ $result = 'OK';
test_geturl(opt('geturl')) if opt('geturl');
usage() if opt('help');
if (opt('help')) {
printf "%s\n", $opt_usage;
exit 0;
}
## read config file because 'daemon' mode may be defined there.
read_config(define($opt{'file'}, default('file')), \%config, \%globals);
@ -860,7 +863,7 @@ do {
read_cache(opt('cache'), \%cache);
print_info() if opt('debug') && opt('verbose');
usage("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage()))
fatal("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage()))
unless exists $ip_strategies{lc opt('use')};
$daemon = $opt{'daemon'};
@ -1327,7 +1330,7 @@ sub init_config {
## sanity check
if (defined $opt{'host'} && defined $opt{'retry'}) {
usage("options -retry and -host (or -option host=..) are mutually exclusive");
fatal("options -retry and -host (or -option host=..) are mutually exclusive");
}
## determine hosts to update (those on the cmd-line, config-file, or failed cached)
@ -1403,16 +1406,6 @@ sub init_config {
}
}
######################################################################
## usage
######################################################################
sub usage {
_msg(1, 1, 'FATAL:', @_) if @_;
printf { @_ ? *STDERR : *STDOUT } "%s\n", $opt_usage;
sendmail() if @_;
exit (@_ ? 1 : 0);
}
######################################################################
## process_args -
######################################################################