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