xref: /freebsd/contrib/ntp/scripts/calc_tickadj/calc_tickadj-opts (revision 2b15cb3d0922bd70ea592f0da9b4a5b167f4d53f)
1*2b15cb3dSCy Schubert# EDIT THIS FILE WITH CAUTION  (calc_tickadj-opts)
2*2b15cb3dSCy Schubert#
3*2b15cb3dSCy Schubert# It has been AutoGen-ed  August 31, 2014 at 04:52:46 AM by AutoGen 5.18.4
4*2b15cb3dSCy Schubert# From the definitions    calc_tickadj-opts.def
5*2b15cb3dSCy Schubert# and the template file   perlopt
6*2b15cb3dSCy Schubert
7*2b15cb3dSCy Schubertuse Getopt::Long qw(GetOptionsFromArray);
8*2b15cb3dSCy SchubertGetopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
9*2b15cb3dSCy Schubert
10*2b15cb3dSCy Schubertmy $usage;
11*2b15cb3dSCy Schubert
12*2b15cb3dSCy Schubertsub usage {
13*2b15cb3dSCy Schubert    my ($ret) = @_;
14*2b15cb3dSCy Schubert    print STDERR $usage;
15*2b15cb3dSCy Schubert    exit $ret;
16*2b15cb3dSCy Schubert}
17*2b15cb3dSCy Schubert
18*2b15cb3dSCy Schubertsub paged_usage {
19*2b15cb3dSCy Schubert    my ($ret) = @_;
20*2b15cb3dSCy Schubert    my $pager = $ENV{PAGER} || '(less || more)';
21*2b15cb3dSCy Schubert
22*2b15cb3dSCy Schubert    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
23*2b15cb3dSCy Schubert    print $usage;
24*2b15cb3dSCy Schubert
25*2b15cb3dSCy Schubert    exit $ret;
26*2b15cb3dSCy Schubert}
27*2b15cb3dSCy Schubert
28*2b15cb3dSCy Schubertsub processOptions {
29*2b15cb3dSCy Schubert    my $args = shift;
30*2b15cb3dSCy Schubert
31*2b15cb3dSCy Schubert    my $opts = {
32*2b15cb3dSCy Schubert        'drift-file' => '/etc/ntp/drift',
33*2b15cb3dSCy Schubert        'tick' => '',
34*2b15cb3dSCy Schubert        'help' => '', 'more-help' => ''
35*2b15cb3dSCy Schubert    };
36*2b15cb3dSCy Schubert    my $argument = '';
37*2b15cb3dSCy Schubert    my $ret = GetOptionsFromArray($args, $opts, (
38*2b15cb3dSCy Schubert        'drift-file|d=s', 'tick|t=i',
39*2b15cb3dSCy Schubert        'help|?', 'more-help'));
40*2b15cb3dSCy Schubert
41*2b15cb3dSCy Schubert    $usage = <<'USAGE';
42*2b15cb3dSCy Schubertcalc_tickadj - Calculates "optimal" value for tick given ntp drift file. - Ver. 4.2.7p467
43*2b15cb3dSCy SchubertUSAGE: calc_tickadj [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
44*2b15cb3dSCy Schubert
45*2b15cb3dSCy Schubert    -d, --drift-file=str         Ntp drift file to use
46*2b15cb3dSCy Schubert    -t, --tick=num               Tick value of this host
47*2b15cb3dSCy Schubert    -?, --help                   Display usage information and exit
48*2b15cb3dSCy Schubert        --more-help              Pass the extended usage text through a pager
49*2b15cb3dSCy Schubert
50*2b15cb3dSCy SchubertOptions are specified by doubled hyphens and their name or by a single
51*2b15cb3dSCy Schuberthyphen and the flag character.
52*2b15cb3dSCy SchubertUSAGE
53*2b15cb3dSCy Schubert
54*2b15cb3dSCy Schubert    usage(0)       if $opts->{'help'};
55*2b15cb3dSCy Schubert    paged_usage(0) if $opts->{'more-help'};
56*2b15cb3dSCy Schubert    $_[0] = $opts;
57*2b15cb3dSCy Schubert    return $ret;
58*2b15cb3dSCy Schubert}
59*2b15cb3dSCy Schubert
60*2b15cb3dSCy SchubertEND { close STDOUT };
61