summaryrefslogtreecommitdiffstats
path: root/urpme
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 /urpme
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 'urpme')
-rw-r--r--urpme34
1 files changed, 10 insertions, 24 deletions
diff --git a/urpme b/urpme
index 74f3af6d..3e1a1070 100644
--- a/urpme
+++ b/urpme
@@ -20,11 +20,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#We only make good software ;-)
-#use strict qw(subs vars refs);
use strict;
use urpm;
+use urpm::args;
-my (@nextargv, $root, $test, $parallel, $auto, $matches, $verbose, $maymatch, $usedistrib, $force, $bug, @l);
+our ($root, $test, $parallel, $auto, $matches, $verbose, $maymatch, $usedistrib, $force, $bug, @l);
my $askok = N("Is this OK?");
# Translator: Add here the keys which might be pressed in the "No"-case.
my $noexpr = N("Nn");
@@ -52,23 +52,8 @@ usage:
}
@ARGV or usage;
-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 };
- /^--?auto$/ and do { $auto = 1; next };
- /^--(no-)?test$/ and do { $test = !$1; next };
- /^--force$/ and do { $force = 1; next };
- /^--root$/ and do { push @nextargv, \$root; next };
- /^--use-distrib$/ and do { push @nextargv, \$usedistrib; next };
- /^--parallel$/ and do { push @nextargv, \$parallel; next };
- /^-(.*)$/ and do { foreach (split //, $1) {
- /[\?h]/ and do { usage; next };
- /a/ and do { $matches = 1; next };
- /v/ and do { $verbose = 1; next };
- die N("urpme: unknown option \"-%s\", check usage with --help\n", $1) } next };
- @nextargv and do { my $r = shift @nextargv; $r and $$r = $_; next };
- push @l, $_;
-}
+urpm::args::parse_cmdline();
+@l = @ARGV;
my $urpm = new urpm;
my $state = {};
@@ -77,11 +62,12 @@ my $state = {};
$verbose or $urpm->{log} = sub {};
#- just configure parallel mode if available.
-$urpm->configure(synthesis => ($parallel and 'none'),
- root => $root,
- parallel => $parallel,
- usedistrib => $usedistrib,
- );
+$urpm->configure(
+ synthesis => ($parallel ? 'none' : ''),
+ root => $root,
+ parallel => $parallel,
+ usedistrib => $usedistrib,
+);
#- examine packages...
my @toremove = $urpm->find_packages_to_remove($state, \@l,