summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/smsg4
-rw-r--r--lib/App/smsg.pm5
-rw-r--r--[-rwxr-xr-x]lib/App/smsg/Command/Talk.pm (renamed from smsbot)32
3 files changed, 33 insertions, 8 deletions
diff --git a/bin/smsg b/bin/smsg
new file mode 100755
index 0000000..6b3723d
--- /dev/null
+++ b/bin/smsg
@@ -0,0 +1,4 @@
+#!/usr/bin/env perl
+
+use App::smsg;
+App::smsg->run;
diff --git a/lib/App/smsg.pm b/lib/App/smsg.pm
new file mode 100644
index 0000000..38bfec1
--- /dev/null
+++ b/lib/App/smsg.pm
@@ -0,0 +1,5 @@
+package App::smsg;
+
+use App::Cmd::Setup -app;
+
+1;
diff --git a/smsbot b/lib/App/smsg/Command/Talk.pm
index f90ebc2..e31725b 100755..100644
--- a/smsbot
+++ b/lib/App/smsg/Command/Talk.pm
@@ -1,7 +1,10 @@
-#!/usr/bin/perl
+package App::smsg::Command::Talk;
+
use strict;
use utf8;
+use App::smsg -command;
+
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
@@ -12,10 +15,12 @@ use AnyEvent::XMPP::Util qw/node_jid res_jid/;
use NetSDS::Kannel;
#use Coro;
-use Getopt::Long::Descriptive;
+sub abstract { 'respond (stupidly simple) when addressed in a Jabber MUC' }
+
+sub usage_desc { '%c talk %o <jid> <password> <talkfile> [<room>]' }
-my ($opt, $usage) = describe_options(
- '%c %o <jid> <password> <talkfile> [<room>]',
+sub opt_spec {
+ return (
['kannelserver=s', "the Kannel server to connect to",
{default => 'localhost'}],
['kannelport=i', "the Kannel port to connect to",
@@ -28,12 +33,19 @@ my ($opt, $usage) = describe_options(
[],
# [ 'verbose|v', "print extra stuff"],
[ 'debug', "print debug stuff"],
- [ 'help', "print usage message and exit"],
-);
+ );
+}
-print($usage->text), exit if ($opt->help or @ARGV < 3);
+sub validate_args {
+ my ($self, $opt, $args) = @_;
-my ($jid, $pw, $inputfile, $room) = @ARGV;
+ $self->usage_error("too few arguments") unless @$args >= 3;
+}
+
+sub execute {
+ my ($self, $opt, $args) = @_;
+
+my ($jid, $pw, $inputfile, $room) = @$args;
# TODO: support overriding full URL
# TODO: use URI module to construct URL
@@ -130,6 +142,10 @@ $cl->start;
$j->wait;
+}
+
+1;
+
__END__
=head1 COPYRIGHT