]> git.refcnt.org Git - distdns.git/blobdiff - client.pl
List remote entries
[distdns.git] / client.pl
index 9992c9de5d97b96d10048631deb0c3b240eff632..e573f9dadfe271826fb5d91844cd090ac4034cce 100755 (executable)
--- a/client.pl
+++ b/client.pl
@@ -45,12 +45,13 @@ Usage: $0
     -d, --debug    server debugging
     -h, --help     this help screen
     -i, --init     initialize session data
+    -l, --list     list remote entries
 USAGE
     exit;
 }
 
 my %opts;
-GetOptions(\%opts, qw(d|debug h|help i|init)) or usage();
+GetOptions(\%opts, qw(d|debug h|help i|init l|list)) or usage();
 usage() if $opts{h};
 
 my $config = Config::Tiny->new;
@@ -104,6 +105,7 @@ my %params = (
     name    => $name,
     debug   => $opts{d} || false,
     init    => $opts{i} || false,
+    list    => $opts{l} || false,
     session => $session,
 );
 
@@ -122,6 +124,21 @@ if ($response->is_success) {
 
     $save_session->($session) if $opts{i};
 
+    if ($opts{l}) {
+        format STDOUT_TOP =
+IP                 Name               PC                      Netz
+=============================================================================
+.
+        foreach my $entry (sort { $a->{netz} cmp $b->{netz} } @{$data->{entries}}) {
+            format STDOUT =
+@<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<<<<<<    @<<<<<<<<<<<<<<
+@$entry{qw(ip name pc netz)}
+.
+            write;
+        }
+        exit;
+    }
+
     my %list;
     foreach my $entry (@{$data->{entries}}) {
         my $host = "$entry->{ip}\t" . join '.', @$entry{qw(name pc netz)};