Home | History | Annotate | Line # | Download | only in scripts
plot_summary-opts revision 1.1
      1  1.1  christos 
      2  1.1  christos # DO NOT EDIT THE FOLLOWING
      3  1.1  christos #
      4  1.1  christos # It's auto generated option handling code  
      5  1.1  christos 
      6  1.1  christos use Getopt::Long qw(GetOptionsFromArray);
      7  1.1  christos Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
      8  1.1  christos 
      9  1.1  christos my $usage;
     10  1.1  christos 
     11  1.1  christos sub usage {
     12  1.1  christos     my ($ret) = @_;
     13  1.1  christos     print STDERR $usage;
     14  1.1  christos     exit $ret;
     15  1.1  christos }
     16  1.1  christos 
     17  1.1  christos sub paged_usage {
     18  1.1  christos     my ($ret) = @_;
     19  1.1  christos     my $pager = $ENV{PAGER} || '(less || more)';
     20  1.1  christos 
     21  1.1  christos     open STDOUT, "| $pager" or die "Can't fork a pager: $!";
     22  1.1  christos     print $usage;
     23  1.1  christos 
     24  1.1  christos     exit $ret;
     25  1.1  christos }
     26  1.1  christos 
     27  1.1  christos sub processOptions {
     28  1.1  christos     my $args = shift;
     29  1.1  christos 
     30  1.1  christos     my $opts = {
     31  1.1  christos         'directory' => '/tmp',
     32  1.1  christos         'identifier' => '',
     33  1.1  christos         'offset-limit' => '0.128',
     34  1.1  christos         'peer' => [],
     35  1.1  christos         'plot-term' => '',
     36  1.1  christos         'output-file' => '',
     37  1.1  christos         'dont-wait' => '',
     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', 'identifier=s', 'offset-limit=f',
     43  1.1  christos         'peer=s', 'plot-term=s', 'output-file=s',
     44  1.1  christos         'dont-wait',
     45  1.1  christos         'help|?', 'more-help'));
     46  1.1  christos 
     47  1.1  christos     $usage = <<'USAGE';
     48  1.1  christos plot_summary - plot statistics generated by summary script
     49  1.1  christos USAGE: plot_summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
     50  1.1  christos 
     51  1.1  christos       , --directory=str          Where the summary files are
     52  1.1  christos       , --identifier=str         Origin of the data
     53  1.1  christos       , --offset-limit=float     Limit of absolute offset
     54  1.1  christos       , --peer=str               Peers to generate plots for
     55  1.1  christos                                    - may appear multiple times
     56  1.1  christos       , --plot-term=str          Gnuplot terminal
     57  1.1  christos       , --output-file=str        Output file
     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 information 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  1.1  christos 
     74