xref: /netbsd-src/external/bsd/ntp/dist/scripts/ntptrace/ntptrace-opts (revision 6cf6fe02a981b55727c49c3d37b0d8191a98c0ee)
1
2# DO NOT EDIT THE FOLLOWING
3#
4# It's auto generated option handling code
5
6use Getopt::Long qw(GetOptionsFromArray);
7Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
8
9my $usage;
10
11sub usage {
12    my ($ret) = @_;
13    print STDERR $usage;
14    exit $ret;
15}
16
17sub paged_usage {
18    my ($ret) = @_;
19    my $pager = $ENV{PAGER} || '(less || more)';
20
21    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
22    print $usage;
23
24    exit $ret;
25}
26
27sub processOptions {
28    my $args = shift;
29
30    my $opts = {
31        'numeric' => '',
32        'max-hosts' => '99',
33        'host' => '127.0.0.1',
34        'help' => '', 'more-help' => ''
35    };
36    my $argument = '[host]';
37    my $ret = GetOptionsFromArray($args, $opts, (
38        'numeric|n', 'max-hosts|m=i', 'host|r=s',
39        'help|?', 'more-help'));
40
41    $usage = <<'USAGE';
42ntptrace - Trace peers of an NTP server
43USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
44
45    -n, --numeric                Print IP addresses instead of hostnames
46    -m, --max-hosts=num          Maximum number of peers to trace
47    -r, --host=str               Single remote host
48    -?, --help                   Display usage information and exit
49      , --more-help              Pass the extended usage information through a pager
50
51Options are specified by doubled hyphens and their name or by a single
52hyphen and the flag character.
53USAGE
54
55    usage(0)       if $opts->{'help'};
56    paged_usage(0) if $opts->{'more-help'};
57
58    if ($argument && $argument =~ /^[^\[]/ && !@$args) {
59        print STDERR "Not enough arguments supplied (See --help/-?)\n";
60        exit 1;
61    }
62    $_[0] = $opts;
63    return $ret;
64}
65
66END { close STDOUT };
67
68