From 187c09223c28208c0f6e0ecb110c6c39985d6d1c Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Fri, 16 Jul 2010 15:51:49 +0200 Subject: [PATCH] Add command-line option handling (-h and -v so far) --- pae2xml.pl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pae2xml.pl b/pae2xml.pl index 1bb2b7d..e6c4bf9 100755 --- a/pae2xml.pl +++ b/pae2xml.pl @@ -10,6 +10,45 @@ #for more details. pae2xml is provided AS IS with NO WARRANTY OF ANY KIND, #INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +our $script = "pae2xml.pl"; +our $version = "1.0"; + +### Handle command-line options + +# import module +use Getopt::Long; + +sub print_help { + print 'pae2xml.pl [OPTIONS...] FILE + + Converts the Plaine & Easie file FILE to MusicXML. If FILE is -, STDIN is used. + + Possible options: + -h, --help Prints out this help message + -v, -- version Prints out version information +'; +} +sub print_version { + print "$script $version + Copyright (C) 2003 Rainer Typke + Copyright (C) 2010 Reinhold Kainhofer <reinhold\@kainhofer.com> +"; +} +sub handle_options { + my $print_help = 0; + my $print_version = 0; + my $result = GetOptions ("help|h" => \$print_help, "version|v" => \$print_version); + if ($print_version) { + print_version (); + exit 0; + } + if ($print_help || (@ARGV == 0)) { + print_help (); + exit 0; + } +} +handle_options (); + $divisions = 960; -- GitLab