diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-07-28 16:38:38 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-07-28 16:38:38 +0200 |
commit | 9b928981cf06af49d13b378c7f9e633ef343767f (patch) | |
tree | 20fe6c29b8c4e6a7e8c0f76df9c762519ab31f62 | |
parent | aee0c6e34baa71f02f0e81a430f67f3d7ae54f31 (diff) |
Add -V/--version switch
-rwxr-xr-x | bin/icli | 3 | ||||
-rw-r--r-- | t/50-icli.t | 7 |
2 files changed, 9 insertions, 1 deletions
@@ -7,6 +7,8 @@ use 5.010; use Getopt::Long qw/:config bundling/; use Term::ANSIColor; +my $version = '0.0+git'; + my ($cache, $config, $data, $extra); my $config_file = '/var/cache/icinga/objects.cache'; my $status_file = '/var/lib/icinga/status.dat'; @@ -182,6 +184,7 @@ GetOptions( 'h|host=s' => sub { push(@for_hosts, split(/,/, $_[1])) }, 'l|list=s' => sub { $list_type = substr($_[1], 0, 1) }, 's|short' => \$short, + 'V|version' => sub { say "icli version $version"; exit 0 }, ); read_objects($status_file, \$data); diff --git a/t/50-icli.t b/t/50-icli.t index 2eafcf5..53fe15a 100644 --- a/t/50-icli.t +++ b/t/50-icli.t @@ -3,7 +3,7 @@ use strict; use warnings; use 5.010; -use Test::Command tests => (19*3); +use Test::Command tests => (20*3); my $icli = 'bin/icli -f t/in/status.dat -c t/in/objects.cache'; @@ -15,6 +15,11 @@ $cmd->exit_is_num(0); $cmd->stdout_is_file('t/out/standard'); $cmd->stderr_is_eq($EMPTY); +$cmd = Test::Command->new(cmd => "$icli -V"); +$cmd->exit_is_num(0); +$cmd->stdout_like(qr{ ^ icli \s version \s \S+ $ }x); +$cmd->stderr_is_eq($EMPTY); + $cmd = Test::Command->new(cmd => "$icli -lh -g local"); $cmd->exit_is_num(0); $cmd->stdout_is_file('t/out/hosts_group_local'); |