final beta with out too many options
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Fri, 08 Aug 2014 11:51:32 +0200
changeset 2 c2fa12eccf27
parent 1 d582082e167d
child 3 982137f0f926
final beta with out too many options
.hgignore
joker
joker.conf.example
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Aug 08 11:51:32 2014 +0200
@@ -0,0 +1,2 @@
+syntax:glob
+joker.conf
--- a/joker	Fri Aug 08 11:26:44 2014 +0200
+++ b/joker	Fri Aug 08 11:51:32 2014 +0200
@@ -5,9 +5,10 @@
 use warnings;
 use if $ENV{DEBUG} => 'Smart::Comments';
 use Data::Dumper;
+use Pod::Usage;
 use WWW::Domain::Registry::Joker;
 
-my %conf = do 'credentials.conf';
+my %conf = do 'joker.conf';
 
 my $joker = WWW::Domain::Registry::Joker->new(
     username => $conf{username},
@@ -19,7 +20,7 @@
 
 given (+shift) {
     when ('register') {
-        my $domain = +shift // die "$0: need domain\n";
+        my $domain = +shift // pod2usage;
         my $proc_id = $joker->do_request(
             'domain-register',
             domain      => $domain,
@@ -34,23 +35,40 @@
         say "ID: $proc_id"
     }
     when ([qw(status result)]) {
-        my $id     = shift;
+        my $id     = shift // '';
         my %result = $joker->result_list;
-        foreach (
-            map  { $result{$_} }
-            sort { $result{$a}{tstamp} <=> $result{$b}{tstamp} }
-            grep { defined $id ? ($id == $_) : 1 } keys %result
-          )
+        foreach (grep {
+	    $id =~ /^\d+$/ ? $_->{procid} == $id : $_->{reqobject} =~ $id 
+	} sort { $a->{tstamp} <=> $b->{tstamp} } values %result)
         {
             $_->{tstamp} =~ s/(?<y>\d{4})(?<m>\d\d)(?<d>\d\d)
 			      (?<H>\d\d)(?<M>\d\d)(?<S>\d\d)\..*
 			     /$+{y}-$+{m}-$+{d} $+{H}:$+{M}:$+{S}/x;
-            say "$_->{reqtype} $_->{tstamp} $_->{reqobject} $_->{status}";
+            say "$_->{procid} $_->{tstamp} $_->{reqtype} $_->{reqobject} $_->{status}";
         }
 
     }
     default {
-        die "$0 [register domain|result [id]]\n"
+	pod2usage;
     }
 }
 
+__END__
+
+=head1 NAME
+
+ joker - register a domain
+
+=head1 SYNOPSIS
+
+ joker register <domain>
+ joker status [<id>|<pattern>]
+
+=head1 DESCRIPTION
+
+This tool registers a domain at joker.
+
+
+=cut
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/joker.conf.example	Fri Aug 08 11:51:32 2014 +0200
@@ -0,0 +1,6 @@
+#! perl
+(
+    # the joker account credentials
+    username => '…',
+    password => '…',
+);