aboutsummaryrefslogtreecommitdiff
path: root/bin/mimefilter
diff options
context:
space:
mode:
authorKylie McClain <kylie@somas.is>2021-05-11 23:23:48 -0400
committerKylie McClain <kylie@somas.is>2021-05-11 23:24:51 -0400
commit810387ef63a19c509411733b98f19e2eb61c40b1 (patch)
tree81dcb2354d986415a663fed36fc266b4cd3c6edf /bin/mimefilter
parent611673db206dcafb013ff06dc5b60664a9b24fd7 (diff)
downloadme-810387ef63a19c509411733b98f19e2eb61c40b1.tar.gz
me-810387ef63a19c509411733b98f19e2eb61c40b1.tar.xz
me-810387ef63a19c509411733b98f19e2eb61c40b1.zip
mimefilter: add verbose flag
Diffstat (limited to 'bin/mimefilter')
-rwxr-xr-xbin/mimefilter10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/mimefilter b/bin/mimefilter
index fe9a912..a66072d 100755
--- a/bin/mimefilter
+++ b/bin/mimefilter
@@ -11,14 +11,14 @@ use File::MimeInfo::Magic ();
use Getopt::Std;
sub HELP_MESSAGE {
- say STDERR "usage: " . (fileparse($0))[0] . " [-!0] TYPE FILES...";
+ say STDERR "usage: " . (fileparse($0))[0] . " [-!0v] TYPE FILES...";
exit 69;
}
sub VERSION_MESSAGE { HELP_MESSAGE; }
my %opt;
-getopts('!0', \%opt) && scalar @ARGV >= 2 or HELP_MESSAGE;
+getopts('!0v', \%opt) && scalar @ARGV >= 2 or HELP_MESSAGE;
my $types = File::MimeInfo->new;
my $filter = $ARGV[0];
@@ -45,7 +45,11 @@ foreach my $file (@ARGV) {
exit 2;
}
- if (not $filetype = $types->mimetype($file)) {
+ my $mimetype = $types->mimetype($file);
+
+ say "$file: $mimetype" if $opt{'v'};
+
+ if (not $filetype = $mimetype) {
say STDERR "warning: couldn't get type for '$file', so it won't be printed";
next;
}