xref: /netbsd-src/external/bsd/ntp/dist/scripts/ntpsweep/ntpsweep-opts (revision 230b95665bbd3a9d1a53658a36b1053f8382a519)
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        'host-list' => [],
32        'peers' => '',
33        'maxlevel' => '',
34        'strip' => '',
35        'host' => '',
36        'help' => '', 'more-help' => ''
37    };
38    my $argument = '[hostfile]';
39    my $ret = GetOptionsFromArray($args, $opts, (
40        'host-list|l=s', 'peers|p', 'maxlevel|m=i',
41        'strip|s=s', 'host|h=s',
42        'help|?', 'more-help'));
43
44    $usage = <<'USAGE';
45ntpsweep - Print various informations about given ntp servers
46USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
47
48    -l, --host-list=str          Host to execute actions on
49                                   - may appear multiple times
50    -p, --peers                  Recursively list all peers a host synchronizes to
51    -m, --maxlevel=num           Traverse peers up to this level (4 is a reasonable number)
52    -s, --strip=str              Strip this string from hostnames
53    -?, --help                   Display usage information and exit
54      , --more-help              Pass the extended usage information through a pager
55
56Options are specified by doubled hyphens and their name or by a single
57hyphen and the flag character.
58USAGE
59
60    usage(0)       if $opts->{'help'};
61    paged_usage(0) if $opts->{'more-help'};
62
63    if ($argument && $argument =~ /^[^\[]/ && !@$args) {
64        print STDERR "Not enough arguments supplied (See --help/-?)\n";
65        exit 1;
66    }
67    $_[0] = $opts;
68    return $ret;
69}
70
71END { close STDOUT };
72
73