diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-04-13 14:53:18 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-04-13 14:53:18 +0000 |
commit | 8c6c3610ab5d9fa60c2e38cbcba71d9517cfd6f6 (patch) | |
tree | 55a953a0177cfc168c02e8fa78f9747fd3956fb2 /urpmi.update | |
parent | 8b6622357e08f5ea263c9ffd1f59506b8a259535 (diff) | |
download | urpmi-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 'urpmi.update')
-rwxr-xr-x | urpmi.update | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/urpmi.update b/urpmi.update index b861657e..a4dcbd7c 100755 --- a/urpmi.update +++ b/urpmi.update @@ -18,43 +18,12 @@ #- this program is based upon old urpmi.addmedia -#use strict qw(subs vars refs); +use strict; use urpm; +use urpm::args; -sub main { - my (@toupdates, %options); - my $urpm = new urpm; - - $options{force} = 0; - $options{noclean} = 1; - while ($_ = shift @_) { - /^--?a$/ and $options{all} = 1, next; - /^--?c$/ and $options{noclean} = 0, next; - /^--?f$/ and ++$options{force}, next; - /^--?z$/ and ++$options{compress}, next; - /^--update$/ and $options{update} = 1, next; - /^--force-key$/ and $options{forcekey} = 1, next; - /^--wget$/ and $urpm->{options}{downloader} = 'wget', next; - /^--curl$/ and $urpm->{options}{downloader} = 'curl', next; - /^--limit-rate$/ and do { $options{limit_rate} = shift @_; next }; - /^--proxy$/ and do { - my ($proxy, $port) = ($_ = shift @_) =~ m,^(?:http://)?([^:]+(:\d+)?)/*$, or - die N("bad proxy declaration on command line\n"); - $proxy .= ":1080" unless $port; - $urpm->{proxy}{http_proxy} = $proxy; - next; - }; - /^--proxy-user$/ and do { - ($_ = shift @_) =~ /(.+):(.+)/, or - die N("bad proxy declaration on command line\n"); - $urpm->{proxy}{user} = $1; - $urpm->{proxy}{pwd} = $2; - next; - }; - /^--no-md5sum$/ and $options{nomd5sum} = 1, next; - /^--?noa$/ and next; #- default, keeped for compability. - /^--?d$/ and next; #- default, keeped for compability. - /^-/ and die N("usage: urpmi.update [options] <name> ... +sub usage { + warn N("usage: urpmi.update [options] <name> ... where <name> is a medium name to update. ") . N(" --help - print this help message. ") . N(" --wget - use wget to retrieve distant files. @@ -70,9 +39,18 @@ where <name> is a medium name to update. ") . N(" -a - select all non-removable media. ") . N(" -c - clean headers cache directory. ") . N(" -f - force generation of hdlist files. -") . (/^--?h(?:elp)$/ ? '' : N("\nunknown options '%s'\n", $_)); - push @toupdates, $_; - } +"); + exit 0; +} + +sub main { + our (@toupdates, %options); + my $urpm = new urpm; + + $options{force} = 0; + $options{noclean} = 1; + + urpm::args::parse_cmdline(urpm => $urpm); $urpm->read_config; exists $options{limit_rate} or $options{limit_rate} = $urpm->{options}{'limit-rate'}; @@ -101,4 +79,4 @@ where <name> is a medium name to update. $urpm->try_umounting_removables; } -main(@ARGV); +main(); |