ntptrace-opts revision 294905
1290650Shselasky# EDIT THIS FILE WITH CAUTION  (ntptrace-opts)
2337115Shselasky#
3290650Shselasky# It has been AutoGen-ed  January 20, 2016 at 04:10:10 AM by AutoGen 5.18.5
4290650Shselasky# From the definitions    ntptrace-opts.def
5290650Shselasky# and the template file   perlopt
6290650Shselasky
7290650Shselaskyuse Getopt::Long qw(GetOptionsFromArray);
8290650ShselaskyGetopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
9290650Shselasky
10290650Shselaskymy $usage;
11290650Shselasky
12290650Shselaskysub usage {
13290650Shselasky    my ($ret) = @_;
14290650Shselasky    print STDERR $usage;
15290650Shselasky    exit $ret;
16290650Shselasky}
17290650Shselasky
18290650Shselaskysub paged_usage {
19290650Shselasky    my ($ret) = @_;
20290650Shselasky    my $pager = $ENV{PAGER} || '(less || more)';
21290650Shselasky
22290650Shselasky    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
23290650Shselasky    print $usage;
24290650Shselasky
25290650Shselasky    exit $ret;
26290650Shselasky}
27290650Shselasky
28290650Shselaskysub processOptions {
29290650Shselasky    my $args = shift;
30290650Shselasky
31290650Shselasky    my $opts = {
32        'numeric' => '',
33        'max-hosts' => '99',
34        'host' => '127.0.0.1',
35        'help' => '', 'more-help' => ''
36    };
37    my $argument = '[host]';
38    my $ret = GetOptionsFromArray($args, $opts, (
39        'numeric|n', 'max-hosts|m=i', 'host|r=s',
40        'help|?', 'more-help'));
41
42    $usage = <<'USAGE';
43ntptrace - Trace peers of an NTP server - Ver. 4.2.8p6
44USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
45
46    -n, --numeric                Print IP addresses instead of hostnames
47    -m, --max-hosts=num          Maximum number of peers to trace
48    -r, --host=str               Single remote host
49    -?, --help                   Display usage information and exit
50        --more-help              Pass the extended usage text through a pager
51
52Options are specified by doubled hyphens and their name or by a single
53hyphen and the flag character.
54USAGE
55
56    usage(0)       if $opts->{'help'};
57    paged_usage(0) if $opts->{'more-help'};
58    $_[0] = $opts;
59    return $ret;
60}
61
62END { close STDOUT };
63