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