From 8e8832f899e173710914645e2fbc45df18baae01 Mon Sep 17 00:00:00 2001 From: Martin Spasov Date: Sat, 16 Apr 2011 17:30:24 +0300 Subject: [PATCH] Some basic usage implementation. Included version. Support for short format options. --- shairport.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/shairport.pl b/shairport.pl index c265892a..83e966bf 100755 --- a/shairport.pl +++ b/shairport.pl @@ -37,6 +37,7 @@ use Digest::MD5 qw/md5_hex/; use POSIX ":sys_wait_h"; eval "use IO::Socket::INET6;"; +my $shairportversion = "0.05"; # Configure the following two options: # AP name - as will be shown in iTunes' menu @@ -51,11 +52,26 @@ my $daemon; # suppose hairtunes is under same directory my $hairtunes_cli = $FindBin::Bin . '/hairtunes'; -GetOptions("apname=s" => \$apname, - "password=s" => \$password, - "d" => \$daemon); +GetOptions("a|apname=s" => \$apname, + "p|password=s" => \$password, + "d" => \$daemon, + "h|help" => \$help); -# use --apname MyName --password secret as arguments +sub usage { + print "Shairport version $shairportversion - Airport Express emulator\n". + "Usage:\n". + "$0 [OPTION...]\n". + "\n". + "Options:\n". + " -a, --apname=AirPort Sets AirPort name\n". + " -p, --password=secret Sets password\n", + " -d Daemon mode\n", + " -h, --help This help\n", + "\n"; + exit; +} + +if (defined($help) && $help == 1) { usage(); } chomp $apname;