1275970Scy# EDIT THIS FILE WITH CAUTION  (ntpsweep-opts)
2275970Scy#
3330567Sgordon# It has been AutoGen-ed  February 27, 2018 at 10:49:57 AM by AutoGen 5.18.5
4275970Scy# From the definitions    ntpsweep-opts.def
5275970Scy# and the template file   perlopt
6275970Scy
7275970Scyuse Getopt::Long qw(GetOptionsFromArray);
8275970ScyGetopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
9275970Scy
10275970Scymy $usage;
11275970Scy
12275970Scysub usage {
13275970Scy    my ($ret) = @_;
14275970Scy    print STDERR $usage;
15275970Scy    exit $ret;
16275970Scy}
17275970Scy
18275970Scysub paged_usage {
19275970Scy    my ($ret) = @_;
20275970Scy    my $pager = $ENV{PAGER} || '(less || more)';
21275970Scy
22275970Scy    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
23275970Scy    print $usage;
24275970Scy
25275970Scy    exit $ret;
26275970Scy}
27275970Scy
28275970Scysub processOptions {
29275970Scy    my $args = shift;
30275970Scy
31275970Scy    my $opts = {
32275970Scy        'host-list' => [],
33275970Scy        'peers' => '',
34275970Scy        'maxlevel' => '',
35275970Scy        'strip' => '',
36275970Scy        'host' => '',
37275970Scy        'help' => '', 'more-help' => ''
38275970Scy    };
39275970Scy    my $argument = '[hostfile]';
40275970Scy    my $ret = GetOptionsFromArray($args, $opts, (
41275970Scy        'host-list|l=s', 'peers|p', 'maxlevel|m=i',
42275970Scy        'strip|s=s', 'host|h=s',
43275970Scy        'help|?', 'more-help'));
44275970Scy
45275970Scy    $usage = <<'USAGE';
46330567Sgordonntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p11
47275970ScyUSAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
48275970Scy
49275970Scy    -l, --host-list=str          Host to execute actions on
50275970Scy                                   - may appear multiple times
51275970Scy    -p, --peers                  Recursively list all peers a host synchronizes to
52275970Scy    -m, --maxlevel=num           Traverse peers up to this level (4 is a reasonable number)
53275970Scy    -s, --strip=str              Strip this string from hostnames
54275970Scy    -?, --help                   Display usage information and exit
55275970Scy        --more-help              Pass the extended usage text through a pager
56275970Scy
57275970ScyOptions are specified by doubled hyphens and their name or by a single
58275970Scyhyphen and the flag character.
59275970ScyUSAGE
60275970Scy
61275970Scy    usage(0)       if $opts->{'help'};
62275970Scy    paged_usage(0) if $opts->{'more-help'};
63275970Scy    $_[0] = $opts;
64275970Scy    return $ret;
65275970Scy}
66275970Scy
67275970ScyEND { close STDOUT };
68