-
Notifications
You must be signed in to change notification settings - Fork 199
/
Script.pm
56 lines (43 loc) · 880 Bytes
/
Script.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package Script;
use strict;
use warnings;
use Getopt::Long ();
use Pod::Usage ();
=head1 NAME
Script - base class for a JBrowse command-line script
=head1 DESCRIPTION
This wheel is smaller than the ones on CPAN, but not really rounder.
=cut
sub new {
my $class = shift;
my $opts = $class->getopts(@_);
return bless { opt => $opts }, $class;
}
sub getopts {
my $class = shift;
my $opts = {
$class->option_defaults,
};
local @ARGV = @_;
Getopt::Long::GetOptions( $opts, $class->option_definitions );
Pod::Usage::pod2usage( -verbose => 2 ) if $opts->{help};
return $opts;
}
sub opt {
if( @_ > 2 ) {
return $_[0]->{opt}{$_[1]} = $_[2];
} else {
return $_[0]->{opt}{$_[1]}
}
}
#override me
sub option_defaults {
( )
}
#override me
sub option_definitions {
( "help|h|?" )
}
sub run {
}
1;