X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=pm2pl;h=3e3af2c667d0c27869fc198701bbb543edfa8672;hb=6d131c770b3b54ee74e0d0b9179114d28dfcec27;hp=b62a6ef152f7384c5069294ceed089381bf4ad02;hpb=d1c03e1606c180175e5c7d91f0aa78d64ae6ac27;p=perltidy.git diff --git a/pm2pl b/pm2pl index b62a6ef..3e3af2c 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 =