Home | History | Annotate | Line # | Download | only in scripts
summary-opts revision 1.1.1.2.2.4
      1  1.1.1.2.2.2  snj # EDIT THIS FILE WITH CAUTION  (summary-opts)
      2  1.1.1.2.2.2  snj #
      3  1.1.1.2.2.4  snj # It has been AutoGen-ed  April 26, 2016 at 08:24:58 PM by AutoGen 5.18.5
      4  1.1.1.2.2.2  snj # From the definitions    summary-opts.def
      5  1.1.1.2.2.2  snj # and the template file   perlopt
      6  1.1.1.2.2.2  snj 
      7  1.1.1.2.2.2  snj use Getopt::Long qw(GetOptionsFromArray);
      8  1.1.1.2.2.2  snj Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
      9  1.1.1.2.2.2  snj 
     10  1.1.1.2.2.2  snj my $usage;
     11  1.1.1.2.2.2  snj 
     12  1.1.1.2.2.2  snj sub usage {
     13  1.1.1.2.2.2  snj     my ($ret) = @_;
     14  1.1.1.2.2.2  snj     print STDERR $usage;
     15  1.1.1.2.2.2  snj     exit $ret;
     16  1.1.1.2.2.2  snj }
     17  1.1.1.2.2.2  snj 
     18  1.1.1.2.2.2  snj sub paged_usage {
     19  1.1.1.2.2.2  snj     my ($ret) = @_;
     20  1.1.1.2.2.2  snj     my $pager = $ENV{PAGER} || '(less || more)';
     21  1.1.1.2.2.2  snj 
     22  1.1.1.2.2.2  snj     open STDOUT, "| $pager" or die "Can't fork a pager: $!";
     23  1.1.1.2.2.2  snj     print $usage;
     24  1.1.1.2.2.2  snj 
     25  1.1.1.2.2.2  snj     exit $ret;
     26  1.1.1.2.2.2  snj }
     27  1.1.1.2.2.2  snj 
     28  1.1.1.2.2.2  snj sub processOptions {
     29  1.1.1.2.2.2  snj     my $args = shift;
     30  1.1.1.2.2.2  snj 
     31  1.1.1.2.2.2  snj     my $opts = {
     32  1.1.1.2.2.2  snj         'directory' => '/var/log/ntp',
     33  1.1.1.2.2.2  snj         'end-date' => '',
     34  1.1.1.2.2.2  snj         'output-directory' => '/tmp',
     35  1.1.1.2.2.2  snj         'peer-dist-limit' => '400',
     36  1.1.1.2.2.2  snj         'skip-time-steps' => '3600',
     37  1.1.1.2.2.2  snj         'start-date' => '19700101',
     38  1.1.1.2.2.2  snj         'help' => '', 'more-help' => ''
     39  1.1.1.2.2.2  snj     };
     40  1.1.1.2.2.2  snj     my $argument = '';
     41  1.1.1.2.2.2  snj     my $ret = GetOptionsFromArray($args, $opts, (
     42  1.1.1.2.2.2  snj         'directory=s', 'end-date=i', 'output-directory=s',
     43  1.1.1.2.2.2  snj         'peer-dist-limit=f', 'skip-time-steps=f', 'start-date=i',
     44  1.1.1.2.2.2  snj         'help|?', 'more-help'));
     45  1.1.1.2.2.2  snj 
     46  1.1.1.2.2.2  snj     $usage = <<'USAGE';
     47  1.1.1.2.2.4  snj summary - compute various stastics from NTP stat files - Ver. 4.2.8p7
     48  1.1.1.2.2.2  snj USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
     49  1.1.1.2.2.2  snj 
     50  1.1.1.2.2.2  snj         --directory=str          Directory containing stat files
     51  1.1.1.2.2.2  snj         --end-date=num           End date
     52  1.1.1.2.2.2  snj         --output-directory=str   Output directory
     53  1.1.1.2.2.2  snj         --peer-dist-limit=float  Peer dist limit
     54  1.1.1.2.2.2  snj         --skip-time-steps=float  Ignore time offsets larger that this
     55  1.1.1.2.2.2  snj         --start-date=num         Start date
     56  1.1.1.2.2.2  snj     -?, --help                   Display usage information and exit
     57  1.1.1.2.2.2  snj         --more-help              Pass the extended usage text through a pager
     58  1.1.1.2.2.2  snj 
     59  1.1.1.2.2.2  snj Options are specified by doubled hyphens and their name or by a single
     60  1.1.1.2.2.2  snj hyphen and the flag character.
     61  1.1.1.2.2.2  snj USAGE
     62  1.1.1.2.2.2  snj 
     63  1.1.1.2.2.2  snj     usage(0)       if $opts->{'help'};
     64  1.1.1.2.2.2  snj     paged_usage(0) if $opts->{'more-help'};
     65  1.1.1.2.2.2  snj     $_[0] = $opts;
     66  1.1.1.2.2.2  snj     return $ret;
     67  1.1.1.2.2.2  snj }
     68  1.1.1.2.2.2  snj 
     69  1.1.1.2.2.2  snj END { close STDOUT };
     70