Added POD documentation to examples/test-server Quancom::Test::Server.
authorheiko@jumper
Mon, 05 Jan 2009 21:44:56 +0100
changeset 14 7ccc679ac5db
parent 13 d6f681329542
child 15 2d41fac09084
Added POD documentation to examples/test-server Quancom::Test::Server. The examples/test-sever even understand --help and --man now.
examples/test-server
lib/Quancom/Test/Server.pm
--- a/examples/test-server	Sun Jan 04 23:44:45 2009 +0100
+++ b/examples/test-server	Mon Jan 05 21:44:56 2009 +0100
@@ -8,9 +8,64 @@
 use warnings;
 use POSIX qw(tmpnam);
 use Getopt::Long;
+use Pod::Usage;
 use Quancom::Test::Server;
 
 $SIG{INT} = sub { warn "got INT, exit now\n"; exit 0; };
 
+GetOptions(
+    "help" => sub { pod2usage(-verbose => 0, exit => 0) },
+    "man"  => sub { pod2usage(-verbose => 2, exit => 0) },
+) or pod2usage;
+
 my $server = new Quancom::Test::Server @ARGV ? $ARGV[0] : tmpnam();
 $server->run;
+
+__END__
+
+=head1 NAME
+
+test-server
+
+=head1 SYNOPSIS
+
+    test-server [socket|[address:]port|-]
+
+=head1 DESCRIPTION
+
+This command starts a test server simulating a Quancom USB-OPTO device.
+It's use is for testing purpose only (testing the Quancom.pm module).
+
+=head1 INVOCATION
+
+On invocation you may pass a parameter:
+
+=over
+
+=item I<socket>
+
+This should be the name of a socket file. The socket file must not
+exist, it will be created. The name has contain at least on slash ("/")
+to be distinguished from a port number.
+
+=item [I<address:>]I<port>
+
+Using this the server will bind to the specified port on 0.0.0.0 or the 
+address supplied.
+
+=item B<->
+
+Using a single "-" the server will communicate over STDIN/STDOUT. Some
+changes in behaviour are implicit set. See L<Quancom::Test::Server> for
+more details. This option is for testing the test server.
+
+=item B<no parameter at all>
+
+If you do not pass anything, the server creates a temporary socket file.
+
+=back
+
+In all cases, the server tells you on STDERR about the "channel" used
+for communication.
+
+=cut
--- a/lib/Quancom/Test/Server.pm	Sun Jan 04 23:44:45 2009 +0100
+++ b/lib/Quancom/Test/Server.pm	Mon Jan 05 21:44:56 2009 +0100
@@ -4,6 +4,24 @@
 # Quancom.pm module and should work like the real USB-OPTO device of
 # Quancom.
 
+#    Quancom test/simulator server
+#    Copyright (C) 2008  Heiko Schlittermann
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    Heiko Schlittermann <hs@schlittermann.de>
+
 use strict;
 use warnings;
 use Carp;
@@ -166,3 +184,34 @@
 }
 
 1;
+
+__END__
+
+=head1 NAME
+
+Quancom::Test::Server
+
+=head1 SYNOPSIS
+
+    use Quancom::Test::Server;
+
+    my $server = new Quancom::Test::Server "/tmp/socket";
+    $server->run();
+
+=head1 METHODS
+
+=over
+
+=item constructor B<new>( I<$address> )
+
+This creates a new server on the I<$address>. The I<$address> may be one
+of the following:
+
+    "-"		    server communications on STDIN/STDOUT
+    [address:]port  server binds to port I<port> on address I<address>
+		    or 0.0.0.0
+    filename	    server creates and binds to the named socket
+		    file (the file gets created by the server and
+		    will be removed afterwards)
+
+=back