From 183d1e48565c838b9f1803086e26dd18b1c64a65 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 10 Sep 2016 09:54:59 -0700 Subject: add --version --- lib/DhMakeELPA/Command/Packaging.pm | 8 ++++++-- lib/DhMakeELPA/Config.pm | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/DhMakeELPA/Command/Packaging.pm b/lib/DhMakeELPA/Command/Packaging.pm index f9714b4..0d932c8 100644 --- a/lib/DhMakeELPA/Command/Packaging.pm +++ b/lib/DhMakeELPA/Command/Packaging.pm @@ -28,7 +28,11 @@ sub extract_basic { $self->debian_dir( $self->main_file('debian') ); $self->find_bins(); $self->pkgname(basename(cwd())); # TODO better? - $self->elpa_version($self->extract_version()); + if ( $self->cfg->version ) { + $self->elpa_version($self->cfg->version); + } else { + $self->elpa_version($self->extract_version()); + } # Find the homepage, license and copyright by looking at the root # .el file, if it exists, of the binary package with the shortest @@ -231,7 +235,7 @@ sub extract_version { if (defined $version) { return $version; } else { - die "Could not determine package version by examining *.el files"; + die "Could not determine package version by examining *.el files.\nPlease specify --version."; } } diff --git a/lib/DhMakeELPA/Config.pm b/lib/DhMakeELPA/Config.pm index 9560a2b..7820191 100644 --- a/lib/DhMakeELPA/Config.pm +++ b/lib/DhMakeELPA/Config.pm @@ -7,13 +7,15 @@ 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!' ); +my @OPTIONS = ( 'pkg-emacsen!', 'version=s' ); my @COMMANDS = ( 'make' ); @@ -38,12 +40,21 @@ use constant DEFAULTS => { source_format => '3.0 (quilt)', }; +# most of this function is from dh-make-perl sub parse_command_line_options { my $self = shift; - # Will probably want to use GetOpt when more than one option - - $self->pkg_emacsen(grep { $_ eq '--pkg-emacsen' } @ARGV); + 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"); -- cgit v1.2.3