2
# OptionsBase.pm: options parser (base functionality) for sbuild
3
# Copyright © 2005 Ryan Murray <rmurray@debian.org>
4
# Copyright © 2005-2009 Roger Leigh <rleigh@debian.org>
5
# Copyright © 2008 Simon McVittie <smcv@debian.org>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see
19
# <http://www.gnu.org/licenses/>.
21
#######################################################################
23
package Sbuild::OptionsBase;
28
use Getopt::Long qw(:config no_ignore_case auto_abbrev gnu_getopt);
29
use Sbuild qw(help_text version_text usage_error);
37
@ISA = qw(Exporter Sbuild::Base);
48
my $self = $class->SUPER::new($conf);
51
$self->add_options("h|help" => sub { help_text($section, $program); },
52
"V|version" => sub {version_text($program); },
54
$self->set_conf('DEBUG',
55
$self->get_conf('DEBUG') + 1); },
57
$self->set_conf('VERBOSE',
58
$self->get_conf('VERBOSE') + 1);
61
$self->set_conf('VERBOSE',
62
$self->get_conf('VERBOSE') - 1)
63
if $self->get_conf('VERBOSE');
68
if (!$self->parse_options()) {
69
usage_error($program, "Error parsing command-line options");
80
if (defined($self->get('Options'))) {
81
%options = (%{$self->get('Options')}, @newopts);
83
%options = (@newopts);
85
$self->set('Options', \%options);
95
return GetOptions((%{$self->get('Options')}));