summaryrefslogtreecommitdiff
path: root/lib/DhMakeELPA/Config.pm
blob: 7820191278e0053dbe209b4ec4d2b6d4199b8477 (plain)
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
57
58
59
60
61
62
63
package DhMakeELPA::Config;

use strict;
use warnings;

our $VERSION = '0.1.0';

use base 'DhMakePerl::Config';

use Getopt::Long;

=head1 NAME

DhMakeELPA::Config - dh-make-elpa configuration class

=cut

my @OPTIONS = ( 'pkg-emacsen!', 'version=s' );

my @COMMANDS = ( 'make' );

# black magic from dh-make-perl:
__PACKAGE__->mk_accessors(
    do {
        my @opts = ( @OPTIONS, @COMMANDS );
        for (@opts) {
            s/[=:!|].*//;
            s/-/_/g;
        }
        @opts;
    },
    'command',
    '_explicitly_set',
);

use constant DEFAULTS => {
                          dh            => 10,
                          data_dir      => '/usr/share/dh-make-elpa',
                          home_dir      => "$ENV{HOME}/.dh-make-elpa",
                          source_format => '3.0 (quilt)',
                         };

# most of this function is from dh-make-perl
sub parse_command_line_options {
    my $self = shift;

    Getopt::Long::Configure( qw( pass_through no_auto_abbrev no_ignore_case ) );
    my %opts;
    GetOptions( \%opts, @OPTIONS )
      or die "Error parsing command-line options\n";

    while ( my ( $k, $v ) = each %opts ) {
        my $field = $k;
        $field =~ s/-/_/g;
        $self->$field( $opts{$k} );
        $self->_explicitly_set->{$k} = 1;
    }

    # TODO
    $self->command("make");
}

1;