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