From 49196e2be932da9062118075b22520f214c23306 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 23 Apr 2004 08:49:33 +0000 Subject: Add a --quiet option to packdrake --- packdrake | 24 ++++++++++++++++-------- packdrake-pm/packdrake.pm | 4 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packdrake b/packdrake index 31841e2..e5a3385 100755 --- a/packdrake +++ b/packdrake @@ -8,7 +8,7 @@ my $default_size = 400000; my $default_ratio = 6; sub usage { - die "packdrake version " . $packdrake::VERSION . " + die qq(packdrake version $packdrake::VERSION Copyright (C) 2000 MandrakeSoft. This is free software and may be redistributed under the terms of the GNU GPL. @@ -17,7 +17,7 @@ usage: --build - build archive with filenames given on standard input. -[1..9] - select appropriate compression ratio, $default_ratio by default. - --dir - set source directory where to search files, \".\" by default. + --dir - set source directory where to search files, "." by default. --size - set maximun chunk size, $default_size by default. --method - select standard compression command method, default is set according to archive filename, example is @@ -30,15 +30,16 @@ usage: --list - list contents of archive. --cat - dump archive, only supported with gzip and bzip2, this write the contents of all file in archive. -"; + --quiet - quiet operation +); } sub main { - my ($file, $mode, $dir, $size, $method, $compress, $uncompress, $ratio); + my ($file, $mode, $dir, $size, $method, $compress, $uncompress, $ratio, $quiet); my @nextargv = (\$file); my @list = (); - #- some quite usefull error message. + #- some quite useful error message. my $error_mode = "packdrake: choose only --build, --extract, --list or --cat\n"; for (@_) { /^--help$/ and do { usage; next }; @@ -51,6 +52,7 @@ sub main { /^--method$/ and do { push @nextargv, \$method; next }; /^--compress$/ and do { push @nextargv, \$compress; next }; /^--uncompress$/ and do { push @nextargv, \$uncompress; next }; + /^--quiet$/ and $quiet = 1, next; /^-(.*)$/ and do { foreach (split //, $1) { /[1-9]/ and do { $ratio = $_; next }; /b/ and do { $mode and die $error_mode; $mode = "build"; @nextargv = (\$file); next }; @@ -60,8 +62,10 @@ sub main { /d/ and do { push @nextargv, \$dir; next }; /s/ and do { push @nextargv, \$size; next }; /m/ and do { push @nextargv, \$method; next }; - die "packdrake: unknown option \"-$1\", check usage with --help\n"; } next }; - $mode =~ /extract|list|cat/ or @nextargv or die "packdrake: unknown option \"$_\", check usage with --help\n"; + die qq(packdrake: unknown option "-$1", check usage with --help\n) } next }; + $mode =~ /extract|list|cat/ + or @nextargv + or die qq(packdrake: unknown option "$_", check usage with --help\n); my $ref = shift @nextargv; $ref ? $$ref = $_ : push @list, $_; $mode ||= "list"; } @@ -82,7 +86,11 @@ sub main { $mode =~ /extract/ && !$dir && !@list and ($mode, @list) = ('list', $file); for ($mode) { /build/ and do { packdrake::build_archive(\*STDIN, $dir, $file, $size, $compress, $uncompress); last }; - /extract/ and do { my $packer = new packdrake($file); $packer->extract_archive($dir, @list); last }; + /extract/ and do { + my $packer = new packdrake($file, quiet => $quiet); + $packer->extract_archive($dir, @list); + last; + }; /list/ and do { packdrake::list_archive($file, @list); last }; /cat/ and do { packdrake::cat_archive($file, @list); last }; die "packdrake: internal error, unable to select right mode?\n"; diff --git a/packdrake-pm/packdrake.pm b/packdrake-pm/packdrake.pm index bd0adf2..3766d81 100644 --- a/packdrake-pm/packdrake.pm +++ b/packdrake-pm/packdrake.pm @@ -3,13 +3,13 @@ package packdrake; use strict; use vars qw($VERSION); -$VERSION = "0.03"; +$VERSION = "0.04"; =head1 NAME packdrake - Mandrake Simple Archive Extractor/Builder -=head1 SYNOPSYS +=head1 SYNOPSIS require packdrake; -- cgit v1.2.1