Skip to content

Commit

Permalink
Added --version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kaoru committed Jul 17, 2013
1 parent b9807d9 commit 6a76cf2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.pod
Expand Up @@ -167,6 +167,12 @@ filled in with capital "X" characters instead.

end of test

=head2 version / v

Show the current version number

% highlight --version

=head2 help / h

Show a brief help message
Expand Down
11 changes: 11 additions & 0 deletions lib/App/highlight.pm
Expand Up @@ -47,6 +47,7 @@ sub opt_spec {
[ 'full-line|l' => "highlight the whole matched line" ],
[ 'one-color|o' => "use only one color for all matches" ],
[ 'show-bad-spaces|b' => "highlight spaces at the end of lines" ],
[ 'version|v' => "show version number" ],
[ 'help|h' => "display a usage message" ],
);
}
Expand All @@ -65,6 +66,10 @@ sub validate_args {
print "\n";
exit;
}
elsif ($opt->{'version'}) {
print $App::highlight::VERSION, "\n";
exit;
}

if (!@$args && !$opt->{'show_bad_spaces'}) {
$self->usage_error(
Expand Down Expand Up @@ -321,6 +326,12 @@ filled in with capital "X" characters instead.
end of test
=head2 version / v
Show the current version number
% highlight --version
=head2 help / h
Show a brief help message
Expand Down
22 changes: 22 additions & 0 deletions t/88-version.t
@@ -0,0 +1,22 @@
use strict;
use warnings;

use File::Basename;
use lib dirname(__FILE__);

use Test::More tests => 1;
use App::Cmd::Tester;
use Test::AppHighlightWords;

use App::highlight;

## version - show version number
{
my $result = test_app('App::highlight' => [ '--version' ]);

like(
$result->stdout,
qr/$App::highlight::VERSION/ms,
"highlight --version => $App::highlight::VERSION"
);
}

0 comments on commit 6a76cf2

Please sign in to comment.