diff options
author | Jonas Smedegaard <dr@jones.dk> | 2012-10-12 22:25:14 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2012-10-12 22:25:14 +0200 |
commit | 686649e23e236198c3c4f2a6a9ac6b6af1fbf1be (patch) | |
tree | b9eab0b7a82d77d8dcc9fc973eb7d82e5d1d589b /lib | |
parent | 8f83787e0333c08d970c0fee4fa542d39f446e51 (diff) |
Implement (crudely simple) status command.
Diffstat (limited to 'lib')
-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"; + } } |