summaryrefslogtreecommitdiffstats
path: root/urpmf
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-04-13 14:53:18 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-04-13 14:53:18 +0000
commit8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6 (patch)
tree55a953a0177cfc168c02e8fa78f9747fd3956fb2 /urpmf
parent8b6622357e08f5ea263c9ffd1f59506b8a259535 (diff)
downloadurpmi-8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6.tar
urpmi-8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6.tar.gz
urpmi-8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6.tar.bz2
urpmi-8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6.tar.xz
urpmi-8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6.zip
Factorize the code to handle command-line options for the urpm* tools
in a module urpm::args.
Diffstat (limited to 'urpmf')
-rwxr-xr-xurpmf67
1 files changed, 18 insertions, 49 deletions
diff --git a/urpmf b/urpmf
index a32033dd..4bf687dc 100755
--- a/urpmf
+++ b/urpmf
@@ -18,9 +18,9 @@
#- along with this program; if not, write to the Free Software
#- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#use strict qw(subs vars refs);
use strict;
use urpm;
+use urpm::args;
sub usage {
print STDERR N("urpmf version %s
@@ -68,61 +68,30 @@ usage:
}
#- default options.
-my $update = 0;
-my $media = '';
-my $excludemedia = '';
-my $sortmedia = '';
-my $synthesis = '';
-my $verbose = 0;
-my $quiet;
-my $uniq = '';
-my $pattern = '';
-my $full = '';
-my $env;
-my (%params, %uniq);
+our $update = 0;
+our $media = '';
+our $excludemedia = '';
+our $sortmedia = '';
+our $synthesis = '';
+our $verbose = 0;
+our $quiet;
+our $uniq = '';
+our $pattern = '';
+our $full = '';
+our $env;
+our (%params, %uniq);
#- parse arguments list.
-my $expr;
-while (defined($_ = shift @ARGV)) {
- /^--help$/ and do { usage; next };
- /^--no-locales$/ and do { undef *N; undef *urpm::N; *N = *urpm::N = sub { sprintf(shift @_, @_) }; next };
- /^--update$/ and do { $update = 1; next };
- /^--media$/ and do { $media = shift @ARGV; next };
- /^--mediums$/ and do { $media = shift @ARGV; next };
- /^--exclude-?media$/ and do { $excludemedia = shift @ARGV; next };
- /^--sort-?media$/ and do { $sortmedia = shift @ARGV; next };
- /^--synthesis$/ and do { $synthesis = shift @ARGV; next };
- /^--verbose$/ and do { $verbose = 1; next };
- /^--quiet$/ and do { $quiet = 1; next };
- /^--uniq$/ and do { $uniq = 1; next };
- /^--all$/ and do { $params{$_} = 1
- foreach qw(filename group size summary description sourcerpm packager buildhost url
- provides requires files conflicts obsoletes); next };
- /^--name$/ and do { $params{filename} = 1; next };
- /^--(group|size|epoch|summary|description|sourcerpm|packager|buildhost|url|provides|requires|files|conflicts|obsoletes)$/ and
- do { $params{$1} = 1; next };
- /^--env$/ and do { $env = shift @ARGV; next };
- /^-v$/ and do { $verbose = 1; next };
- /^-q$/ and do { $quiet = 1; next };
- /^-u$/ and do { $uniq = 1; next };
- /^-i$/ and do { $pattern = 'i'; next };
- /^-f$/ and do { $full = 'full'; next };
- /^-e$/ and do { $expr .= '('.(shift @ARGV).')'; next };
- /^-a$/ and do { $expr .= ' && '; next };
- /^-o$/ and do { $expr .= ' || '; next };
- /^[!\(\)]$/ and do { $expr .= $_; next };
- #- assume a regex directly unless a ++ is inside the string, someother to use ?
- /\+\+/ and $_ = quotemeta $_;
- $expr .= 'm{'.$_.'}'.$pattern;
-}
+our $expr;
+urpm::args::parse_cmdline();
my $urpm = new urpm;
$verbose or $urpm->{log} = sub {};
foreach (scalar(keys %params)) {
- $_ eq 0 and do { defined $quiet or $quiet = 1; $params{files} = 1 };
- $_ eq 1 and do { defined $quiet or $quiet = 1 };
- $_ > 1 and do { defined $quiet or $quiet = 0 };
+ $_ == 0 and do { defined $quiet or $quiet = 1; $params{files} = 1 };
+ $_ == 1 and do { defined $quiet or $quiet = 1 };
+ $_ > 1 and do { defined $quiet or $quiet = 0 };
}
#- build callback according expression.