diff options
-rw-r--r-- | lib/App/smsg/Command/Status.pm | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/App/smsg/Command/Status.pm b/lib/App/smsg/Command/Status.pm index f0dfb70..22e1823 100644 --- a/lib/App/smsg/Command/Status.pm +++ b/lib/App/smsg/Command/Status.pm @@ -14,7 +14,6 @@ use App::smsg -command; use namespace::clean; use NetSDS::Kannel; -#use Coro; use constant abstract => q (Check status of platform(s).); use constant usage_desc => '%c status %o <platform>...'; @@ -25,16 +24,20 @@ DESCRIPTION use constant opt_spec => ( ['kannelserver=s', "the Kannel server to connect to", {default => 'localhost'}], - ['kannelport=i', "the Kannel port to connect to", + ['kanneladminport=i', "the Kannel admin port to connect to", + {default => 13000}], + ['kanneladminpasswd=s', "the Kannel admin password to authenticate with", + {default => ''}], + ['kannelsendsmsport=i', "the Kannel sendsms port to connect to", {default => 13013}], - ['kanneluser=s', "the Kannel users to authenticate as", + ['kannelsendsmsuser=s', "the Kannel sendsms user to authenticate as", {default => 'tester'}], - ['kannelpasswd=s', "the Kannel password to authenticate with", + ['kannelsendsmspasswd=s', "the Kannel sendsms password to authenticate with", {default => 'foobar'}], ['kannelsmsc=s', "the Kannel SMSC to correspond with"], [], - ['f|follow', "keep connection open and emit each change of state"], - [], +# TODO ['f|follow', "keep connection open and emit each change of state"], +# [], # [ 'verbose|v', "print extra stuff"], [ 'debug', "print debug stuff"], ); @@ -45,13 +48,20 @@ sub execute { # TODO: support overriding full URL # TODO: use URI module to construct URL my $kannel = NetSDS::Kannel->new( - sendsms_url => 'http://' . $opt->kannelserver . ':' . $opt->kannelport . '/cgi-bin/sendsms', - sendsms_user => $opt->kanneluser, - sendsms_passwd => $opt->kannelpasswd, + admin_url => 'http://' . $opt->kannelserver . ':' . $opt->kanneladminport . '/', + admin_passwd => $opt->kanneladminpasswd, + sendsms_url => 'http://' . $opt->kannelserver . ':' . $opt->kannelsendsmsport . '/cgi-bin/sendsms', + sendsms_user => $opt->kannelsendsmsuser, + sendsms_passwd => $opt->kannelsendsmspasswd, default_smsc => $opt->kannelsmsc, ); - die 'FIXME: unimplemented!'; + my $status = $kannel->status(); + + print $$status{status}."\n"; + for my $i ( 0 .. $#{ $$status{smsc} }) { + print $$status{smsc}[$i]{id}.': '.$$status{smsc}[$i]{status}."\n"; + } } |