diff --git a/README.md b/README.md
index 2e7faffc74bb98e645a0cb6954b763631e00fa4a..4f09fa707771627637d44838bcd3bc187c8a4227 100644
--- a/README.md
+++ b/README.md
@@ -115,6 +115,7 @@ -n <number> : limit the resultset to <number> of lines
-o <fields> : sort your output by the given fields (sequence matters!) in descending order
allowed values: any comma separated combination of the values of -t and -s param and 'count'
-r : sort in reverse (ascending) order
+ -e : skip lines with empty selected or grouping fields
examples:
phosta -E jpg,jpeg,tiff -D ~/Documents/stats.db -p ~/Pictures
diff --git a/phosta.pl b/phosta.pl
index 54dafd582eebc0e06229c13e9f6cc17f664d5b28..087fcdbf52ff9bb4df5e42e5c8d259393d2ea50c 100755
--- a/phosta.pl
+++ b/phosta.pl
@@ -35,10 +35,11 @@ our $opt_n=undef;
our $opt_o='count';
our $opt_r=0;
our $opt_f=undef;
+our $opt_e=0;
getconfig($configfile);
-getopts('vcrp:n:g:s:t:D:E:o:f:') or die "Invalid parameters provided! See 'phosta --help' for more details.";
+getopts('vcrp:n:g:s:t:D:E:o:f:e') or die "Invalid parameters provided! See 'phosta --help' for more details.";
validate() or die "Invalid parameters provided! See 'phosta --help' for more details.";
my $dsn = "DBI:SQLite:dbname=$opt_D";
@@ -230,7 +231,6 @@
foreach (get_filters())
{
-
push @wherearray, @{$_}[0] . (@{$_}[1] =~ /!/ ? ' NOT' : '') . " LIKE '%@{$_}[2]%'";
}
@@ -288,6 +288,19 @@ foreach (@$rows)
{
if (!defined($opt_n) || ($currentlines < $opt_n))
{
+ if ($opt_e)
+ {
+ my $skip = 1;
+ for (my $i=0; $i < (scalar @$_ - 2); $i++)
+ {
+ @$_[$i] eq '-' or $skip = 0;
+ }
+ if ($skip)
+ {
+ $skippedlines++;
+ next;
+ }
+ }
$tb->row(@$_);
$currentlines++;
}
@@ -314,12 +327,13 @@ }
say '';
}
- if (defined($opt_n))
+ if (defined($opt_n) || $opt_e)
{
- say 'Showing '. color('bold'). "top $currentlines". color('reset'). ' results, skipping '. color('italic') . "$skippedlines lines".color('reset') .'.';
+ say 'Showing '. color('bold'). "$currentlines". color('reset'). ' results, skipping '. color('italic') . "$skippedlines lines".color('reset') .'.';
}
say 'A total of '. color('bold'). "$sum images". color('reset') .' matched your criteria.';
say '';
+
if (scalar @$rows) { say $tb->draw; }
}
@@ -368,6 +382,7 @@ say ' -n <number> : limit the resultset to <number> of lines';
say ' -o <fields> : sort your output by the given fields (sequence matters!) in descending order';
say ' allowed values: any comma separated combination of the values of -t and -s param and \'count\'';
say ' -r : sort in reverse (ascending) order';
+ say ' -e : skip lines with empty selected or grouping fields';
say '';
say 'examples:';
say ' phosta -E jpg,jpeg,tiff -D ~/Documents/stats.db -p ~/Pictures';