From: Steve Hancock Date: Thu, 23 Sep 2021 00:55:25 +0000 (-0700) Subject: update utility pm2pl with flags -D -o ofname X-Git-Tag: 20211029~60 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d216528e9952b285961d02663db13ff3f9525cf8;p=perltidy.git update utility pm2pl with flags -D -o ofname --- diff --git a/pm2pl b/pm2pl index b62a6ef1..090c66de 100755 --- a/pm2pl +++ b/pm2pl @@ -1,5 +1,6 @@ #!/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" @@ -8,12 +9,38 @@ use strict; # This is also useful for making a copy of previous versions for parallel # debugging sessions. -# usage: -# perl pm2pl +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 +78,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 =