diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-07-30 00:39:28 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-07-30 00:39:28 +0200 |
commit | e8d4fa8c1cacc4062a573c46ced2e7c1ee25212a (patch) | |
tree | b0fbde7c3b6fa09d6b750c662fea0ebbd7ab31df | |
parent | e22b73286bbf862090785adf022093dab751f62d (diff) |
icli -lq: Support filtering output with -h/-g
-rwxr-xr-x | bin/icli | 6 | ||||
-rw-r--r-- | t/50-icli.t | 7 | ||||
-rw-r--r-- | t/out/list_queue_aneurysm | 13 |
3 files changed, 24 insertions, 2 deletions
@@ -131,6 +131,10 @@ sub display_queue { (values %{$data->{hosts}}, map { @{$_} } values %{$data->{services}}); + if (@for_hosts) { + @queue = grep { $_->{host_name} ~~ \@for_hosts } @queue; + } + printf( "%-25.25s %-20.20s %-19s %-19s\n", 'Host', @@ -239,7 +243,7 @@ foreach my $group (@for_groups) { } } -if (@for_hosts) { +if (@for_hosts and $list_type ~~ [qw/s h/]) { foreach my $host (@for_hosts) { if (have_host($host)) { display_host( diff --git a/t/50-icli.t b/t/50-icli.t index d5a4b65..2ab76e4 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 => (21*3); +use Test::Command tests => (22*3); my $icli = 'bin/icli -f t/in/status.dat -c t/in/objects.cache'; @@ -80,6 +80,11 @@ $cmd->exit_is_num(0); $cmd->stdout_is_file('t/out/list_queue'); $cmd->stderr_is_eq($EMPTY); +$cmd = Test::Command->new(cmd => "$icli -lq -h aneurysm"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('t/out/list_queue_aneurysm'); +$cmd->stderr_is_eq($EMPTY); + $cmd = Test::Command->new(cmd => "$icli -g invalid"); $cmd->exit_isnt_num(0); diff --git a/t/out/list_queue_aneurysm b/t/out/list_queue_aneurysm new file mode 100644 index 0000000..dc0f3fa --- /dev/null +++ b/t/out/list_queue_aneurysm @@ -0,0 +1,13 @@ +Host Service Last Check Next Check +aneurysm SMTP 2010-07-28 10:43:36 2010-07-28 10:48:36 +aneurysm Disk: /data 2010-07-28 10:43:45 2010-07-28 10:48:45 +aneurysm Disk: /boot 2010-07-28 10:44:01 2010-07-28 10:49:01 +aneurysm Disk: /home 2010-07-28 10:44:56 2010-07-28 10:49:56 +aneurysm Load 2010-07-28 10:45:31 2010-07-28 10:50:31 +aneurysm Processes 2010-07-28 10:45:48 2010-07-28 10:50:48 +aneurysm HTTPS 2010-07-28 10:46:06 2010-07-28 10:51:06 +aneurysm Disk: / 2010-07-28 10:46:21 2010-07-28 10:51:21 +aneurysm 2010-07-28 10:47:26 2010-07-28 10:52:36 +aneurysm HTTP 2010-07-28 10:48:18 2010-07-28 10:53:18 +aneurysm SSH 2010-07-28 10:48:33 2010-07-28 10:53:33 +aneurysm SSH password login d 2010-07-28 10:47:48 2010-07-28 11:02:48 |