xref: /freebsd/contrib/ntp/scripts/update-leap/update-leap-opts (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1a25439b6SCy Schubert# EDIT THIS FILE WITH CAUTION  (update-leap-opts)
2a25439b6SCy Schubert#
3*f5f40dd6SCy Schubert# It has been AutoGen-ed  May 25, 2024 at 12:05:57 AM by AutoGen 5.18.16
4a25439b6SCy Schubert# From the definitions    update-leap-opts.def
5a25439b6SCy Schubert# and the template file   perlopt
6a25439b6SCy Schubert
7a25439b6SCy Schubertuse Getopt::Long qw(GetOptionsFromArray);
8a25439b6SCy SchubertGetopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
9a25439b6SCy Schubert
10a25439b6SCy Schubertmy $usage;
11a25439b6SCy Schubert
12a25439b6SCy Schubertsub usage {
13a25439b6SCy Schubert    my ($ret) = @_;
14a25439b6SCy Schubert    print STDERR $usage;
15a25439b6SCy Schubert    exit $ret;
16a25439b6SCy Schubert}
17a25439b6SCy Schubert
18a25439b6SCy Schubertsub paged_usage {
19a25439b6SCy Schubert    my ($ret) = @_;
20a25439b6SCy Schubert    my $pager = $ENV{PAGER} || '(less || more)';
21a25439b6SCy Schubert
22a25439b6SCy Schubert    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
23a25439b6SCy Schubert    print $usage;
24a25439b6SCy Schubert
25a25439b6SCy Schubert    exit $ret;
26a25439b6SCy Schubert}
27a25439b6SCy Schubert
28a25439b6SCy Schubertsub processOptions {
29a25439b6SCy Schubert    my $args = shift;
30a25439b6SCy Schubert
31a25439b6SCy Schubert    my $opts = {
32a25439b6SCy Schubert        'source-url' => '',
33a25439b6SCy Schubert        'ipv4' => '',
34a25439b6SCy Schubert        'destination' => '',
35a25439b6SCy Schubert        'expiration' => '',
36a25439b6SCy Schubert        'ntp-conf-file' => '',
37a25439b6SCy Schubert        'force-update' => '',
38a25439b6SCy Schubert        'dont-wait' => '',
39a25439b6SCy Schubert        'help' => '', 'more-help' => ''
40a25439b6SCy Schubert    };
41a25439b6SCy Schubert    my $argument = '';
42a25439b6SCy Schubert    my $ret = GetOptionsFromArray($args, $opts, (
43a25439b6SCy Schubert        'source-url|s=s', 'ipv4|4', 'destination|d=f',
44a25439b6SCy Schubert        'expiration|e=s', 'ntp-conf-file|f=s', 'force-update|F',
45a25439b6SCy Schubert        'dont-wait',
46a25439b6SCy Schubert        'help|?', 'more-help'));
47a25439b6SCy Schubert
48a25439b6SCy Schubert    $usage = <<'USAGE';
49*f5f40dd6SCy Schubertupdate-leap - leap-seconds file manager/updater - Ver. 4.2.8p18
50a25439b6SCy SchubertUSAGE: update-leap [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
51a25439b6SCy Schubert
52a25439b6SCy Schubert    -s, --source-url=str         The URL of the master copy of the leapseconds file
53a25439b6SCy Schubert    -4, --ipv4                   Use only IPv4 addresses for DNS name resolution
54a25439b6SCy Schubert    -d, --destination=float      Filename on the local system
55a25439b6SCy Schubert    -e, --expiration=str         Refresh the leapfile this long before it expires
56a25439b6SCy Schubert    -f, --ntp-conf-file=str      Location of the ntp.conf file
57a25439b6SCy Schubert    -F, --force-update           Force update of the leapfile
58a25439b6SCy Schubert        --dont-wait              Don't wait for keystroke between plots
59a25439b6SCy Schubert    -?, --help                   Display usage information and exit
60a25439b6SCy Schubert        --more-help              Pass the extended usage text through a pager
61a25439b6SCy Schubert
62a25439b6SCy SchubertOptions are specified by doubled hyphens and their name or by a single
63a25439b6SCy Schuberthyphen and the flag character.
64a25439b6SCy SchubertUSAGE
65a25439b6SCy Schubert
66a25439b6SCy Schubert    usage(0)       if $opts->{'help'};
67a25439b6SCy Schubert    paged_usage(0) if $opts->{'more-help'};
68a25439b6SCy Schubert    $_[0] = $opts;
69a25439b6SCy Schubert    return $ret;
70a25439b6SCy Schubert}
71a25439b6SCy Schubert
72a25439b6SCy SchubertEND { close STDOUT };
73