summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-10-18 10:29:55 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-10-18 10:29:55 +0000
commitf62bde1d618ccfbb62ff88d1efaf88647d4d0d83 (patch)
tree4e0d204b0dc7c1269eef742716205cc6b6be4c9d
parent1c8ac2443832a0bba460f06f7f69429652c18661 (diff)
downloadurpmi-f62bde1d618ccfbb62ff88d1efaf88647d4d0d83.tar
urpmi-f62bde1d618ccfbb62ff88d1efaf88647d4d0d83.tar.gz
urpmi-f62bde1d618ccfbb62ff88d1efaf88647d4d0d83.tar.bz2
urpmi-f62bde1d618ccfbb62ff88d1efaf88647d4d0d83.tar.xz
urpmi-f62bde1d618ccfbb62ff88d1efaf88647d4d0d83.zip
Synamically generate option parsing callbacks for urpmf
-rw-r--r--urpm/args.pm77
1 files changed, 53 insertions, 24 deletions
diff --git a/urpm/args.pm b/urpm/args.pm
index dc6d5b90..b354685e 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -31,6 +31,15 @@ sub import {
}
}
+# used by urpmf
+sub add_param_closure {
+ my (@tags) = @_;
+ return sub {
+ $::qf .= join ':', '', map "%$_", @tags;
+ $::params{$_} = 1 for @tags;
+ };
+}
+
# options specifications for Getopt::Long
my %options_spec = (
@@ -135,35 +144,29 @@ my %options_spec = (
a => \$::matches,
},
+ #- see also below, autogenerated callbacks
urpmf => {
- all => sub {
- foreach my $k (qw(filename group size summary description sourcerpm
- packager buildhost url provides requires files conflicts obsoletes))
- { $::params{$k} = 1 }
- },
- arch => \$::params{arch},
- buildhost => \$::params{buildhost},
- buildtime => \$::params{buildtime},
+ all => add_param_closure(qw(
+ buildhost
+ conflicts
+ description
+ filename
+ files
+ group
+ obsoletes
+ packager
+ provides
+ requires
+ size
+ sourcerpm
+ summary
+ url
+ )),
conffiles => \$::params{conf_files},
- conflicts => \$::params{conflicts},
debug => \$::debug,
- description => \$::params{description},
- distribution => \$::params{distribution},
- epoch => \$::params{epoch},
- files => \$::params{files},
- group => \$::params{group},
literal => \$::literal,
- name => \$::params{filename},
- obsoletes => \$::params{obsoletes},
- packager => \$::params{packager},
- provides => \$::params{provides},
- requires => \$::params{requires},
- size => \$::params{size},
- sourcerpm => \$::params{sourcerpm},
- summary => \$::params{summary},
+ qf => \$::qf,
'uniq|u' => \$::uniq,
- url => \$::params{url},
- vendor => \$::params{vendor},
'verbose|v' => \$::verbose,
m => \$::params{media},
i => sub { $::pattern = 'i' },
@@ -317,6 +320,32 @@ my %options_spec = (
);
+# generate urpmf options callbacks
+
+foreach my $k (qw(
+ arch
+ buildhost
+ buildtime
+ conflicts
+ description
+ distribution
+ epoch
+ files
+ group
+ filename
+ obsoletes
+ packager
+ provides
+ requires
+ size
+ sourcerpm
+ summary
+ url
+ vendor
+)) {
+ $options_spec{urpmf}{$k} = add_param_closure($k);
+}
+
# common options setup
foreach my $k ("help|h", "version", "no-locales", "test!", "force", "root=s", "use-distrib=s",