From dbc826d4abc171bed44d1f42a22c2c5bdfef38ef Mon Sep 17 00:00:00 2001
From: dscho <dscho>
Date: Fri, 21 Jan 2005 14:30:05 +0000
Subject: use Getopt

---
 VisualNaCro/recorder.pl | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/VisualNaCro/recorder.pl b/VisualNaCro/recorder.pl
index f84b3f6..bbe3f25 100644
--- a/VisualNaCro/recorder.pl
+++ b/VisualNaCro/recorder.pl
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 
+use Getopt::Long;
 use nacro;
 
 # TODO: take options
@@ -9,6 +10,37 @@ $server="localhost";
 $port=5900;
 $listen_port=5923;
 
+if(!GetOptions(
+	"script:s" => \$output,
+	"listen:i" => \$listen_port
+) || $#ARGV!=0) {
+	print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] server[:port]\n";
+	exit 2;
+}
+
+$output=~s/\.pl$//;
+
+$server=$ARGV[0];
+
+if($server=~/^(.*):(\d+)$/) {
+	$server=$1;
+	$port=$2;
+	if($2<100) {
+		$port+=5900;
+	}
+}
+
+if($listen_port<100) {
+	$listen_port+=5900;
+}
+
+# do not overwrite script
+
+if(stat("$output.pl")) {
+	print STDERR "Will not overwrite $output.pl\n";
+	exit 2;
+}
+
 # start connection
 $vnc=nacro::initvnc($server,$port,$listen_port);
 
-- 
cgit v1.2.3

