Support filtering by version in App::NAOdash
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 26 Dec 2015 21:29:38 +0000 (23:29 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 26 Dec 2015 21:33:34 +0000 (23:33 +0200)
lib/App/NAOdash.pm
naodash

index 85a52709b034e372002af8b01c908f4cd5270ec1..d6df6bef999c6238b71c7a65bff732aa4d436912 100644 (file)
@@ -94,12 +94,12 @@ EOF
 }
 
 sub run {
 }
 
 sub run {
-       my ($user_or_path) = @_;
+       my ($args, $user_or_path) = @_;
        my $stats;
        if ($user_or_path =~ /^\w+$/) { # Looks like a user
        my $stats;
        if ($user_or_path =~ /^\w+$/) { # Looks like a user
-               $stats = naodash_user $user_or_path
+               $stats = naodash_user $args, $user_or_path
        } else {
        } else {
-               $stats = naodash_xlog read_file $user_or_path
+               $stats = naodash_xlog $args, read_file $user_or_path
        }
        print encode 'UTF-8', naodash_to_ansi $stats ## no critic (RequireCheckedSyscalls)
 }
        }
        print encode 'UTF-8', naodash_to_ansi $stats ## no critic (RequireCheckedSyscalls)
 }
diff --git a/naodash b/naodash
index 52b175ea485ec13439440b7dbdedecd833f4c84f..ae0a604eff1175b8554342dfb7698cc964eb166a 100755 (executable)
--- a/naodash
+++ b/naodash
@@ -4,8 +4,19 @@ use strict;
 use warnings;
 
 use App::NAOdash;
 use warnings;
 
 use App::NAOdash;
+use Getopt::Long;
 
 
-App::NAOdash::run(@ARGV);
+my %args = (
+       include_versions => [],
+       exclude_versions => [],
+);
+
+GetOptions(
+       "exclude-version=s@", \$args{exclude_versions},
+       "include-version=s@", \$args{include_versions},
+);
+
+App::NAOdash::run(\%args, @ARGV);
 
 __END__
 
 
 __END__
 
@@ -20,6 +31,11 @@ naodash - Analyze NetHack xlogfiles and extract statistics (command-line interfa
   naodash mgv # Show statistics for the mgv user on NAO
   naodash /path/to/xlogfile # Show statistics for a given xlogfile
 
   naodash mgv # Show statistics for the mgv user on NAO
   naodash /path/to/xlogfile # Show statistics for a given xlogfile
 
+  # Show statistics for mgv, only including games played on 3.4.3 or 3.60
+  naodash --include-versions=3.6.0 --include-versions=3.4.3 mgv
+  # Show statistics for mgv, ignoring games played on 3.6.0
+  naodash --exclude-versions=3.6.0 mgv
+
 =head1 DESCRIPTION
 
 naodash is a command-line interface to L<NetHack::NAOdash>. It takes a
 =head1 DESCRIPTION
 
 naodash is a command-line interface to L<NetHack::NAOdash>. It takes a
@@ -28,6 +44,25 @@ results of the analysis. A terminal with ANSI escape code support is
 required. Do not parse this command's output. For computer-readable
 output, please use the L<NetHack::NAOdash> library directly.
 
 required. Do not parse this command's output. For computer-readable
 output, please use the L<NetHack::NAOdash> library directly.
 
+=head1 OPTIONS
+
+=over
+
+=item B<--include-version>=I<version>
+
+Only consider games played on this version of NetHack. Can be
+specified multiple times to include multiple versions.
+
+=item B<--exclude-version>=I<version>
+
+Do not consider games played on this version of NetHack. Can be
+specified multiple times to exclude multiple versions.
+
+=back
+
+If a version is included and excluded at the same time, games played
+on that version will not be considered.
+
 =head1 ENVIRONMENT
 
 =over
 =head1 ENVIRONMENT
 
 =over
This page took 0.012608 seconds and 4 git commands to generate.