Home | History | Annotate | Line # | Download | only in scripts
summary-opts revision 1.1.1.12
      1   1.1.1.2  christos # EDIT THIS FILE WITH CAUTION  (summary-opts)
      2       1.1  christos #
      3  1.1.1.12  christos # It has been AutoGen-ed  August 14, 2018 at 08:09:40 AM by AutoGen 5.18.5
      4   1.1.1.2  christos # From the definitions    summary-opts.def
      5   1.1.1.2  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         'directory' => '/var/log/ntp',
     33       1.1  christos         'end-date' => '',
     34       1.1  christos         'output-directory' => '/tmp',
     35       1.1  christos         'peer-dist-limit' => '400',
     36       1.1  christos         'skip-time-steps' => '3600',
     37       1.1  christos         'start-date' => '19700101',
     38       1.1  christos         'help' => '', 'more-help' => ''
     39       1.1  christos     };
     40       1.1  christos     my $argument = '';
     41       1.1  christos     my $ret = GetOptionsFromArray($args, $opts, (
     42       1.1  christos         'directory=s', 'end-date=i', 'output-directory=s',
     43       1.1  christos         'peer-dist-limit=f', 'skip-time-steps=f', 'start-date=i',
     44       1.1  christos         'help|?', 'more-help'));
     45       1.1  christos 
     46       1.1  christos     $usage = <<'USAGE';
     47  1.1.1.12  christos summary - compute various stastics from NTP stat files - Ver. 4.2.8p12
     48       1.1  christos USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
     49       1.1  christos 
     50   1.1.1.2  christos         --directory=str          Directory containing stat files
     51   1.1.1.2  christos         --end-date=num           End date
     52   1.1.1.2  christos         --output-directory=str   Output directory
     53   1.1.1.2  christos         --peer-dist-limit=float  Peer dist limit
     54   1.1.1.2  christos         --skip-time-steps=float  Ignore time offsets larger that this
     55   1.1.1.2  christos         --start-date=num         Start date
     56       1.1  christos     -?, --help                   Display usage information and exit
     57   1.1.1.2  christos         --more-help              Pass the extended usage text through a pager
     58       1.1  christos 
     59       1.1  christos Options are specified by doubled hyphens and their name or by a single
     60       1.1  christos hyphen and the flag character.
     61       1.1  christos USAGE
     62       1.1  christos 
     63       1.1  christos     usage(0)       if $opts->{'help'};
     64       1.1  christos     paged_usage(0) if $opts->{'more-help'};
     65       1.1  christos     $_[0] = $opts;
     66       1.1  christos     return $ret;
     67       1.1  christos }
     68       1.1  christos 
     69       1.1  christos END { close STDOUT };
     70