X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=pm2pl;h=699293639bf78381ecd44e2bdc93eb4fe50adcd2;hb=880633cc084e9d787eb9f760d3851c5d660db17c;hp=b62a6ef152f7384c5069294ceed089381bf4ad02;hpb=57d829ae0e2c75828f8ecc9c7139579350927dbc;p=perltidy.git diff --git a/pm2pl b/pm2pl index b62a6ef..6992936 100755 --- a/pm2pl +++ b/pm2pl @@ -1,19 +1,39 @@ #!/usr/bin/env perl use strict; +use Getopt::Long; -# This script will recombine the perltidy binary script and all of its modules -# into a single, monolithic script. I use it for making a temporary "sandbox" -# for debugging. +my $usage = < 1 [ for extra testing when debugging ] +EOM + +my @option_string = qw( + h + o:s + D +); + +my %Opts = (); +if ( !GetOptions( \%Opts, @option_string ) ) { + die "Programming Bug: error in setting default options"; +} + +if ( $Opts{h} ) { + print $usage; + exit 1; +} # This should work for a system with File::Spec, # and for older Windows/Unix systems without File::Spec. @@ -51,44 +71,59 @@ unless ($missing_file_spec) { my $VERSION = get_version("lib/Perl/Tidy.pm"); my $outfile = "perltidy-$VERSION.pl"; -open OUTFILE, "> $outfile" or die "can't open file '$outfile' : $!\n"; -print "Creating standalone formatter script '$outfile' ....\n "; +if ( $Opts{o} ) { $outfile = $Opts{o} } +my $fh_out; +open( $fh_out,, ">", $outfile ) or die "can't open file '$outfile' : $!\n"; +print "Creating standalone perltidy script '$outfile' ...."; # first, open the script and copy the first (hash-bang) line # (Note: forward slashes in file names here will work in Windows) -open SCRIPT, "< $script" or die "can't open script file '$script' : $!\n"; -my $hash_bang =