Break out packages into separate files

This commit is contained in:
Dan Church 2022-11-16 11:33:08 -06:00
parent f04cbac723
commit b1b4e18e05
Signed by: h3xx
GPG key ID: EA2BF379CD2CDBD0
11 changed files with 725 additions and 611 deletions

60
util/squash Executable file
View file

@ -0,0 +1,60 @@
#!/usr/bin/perl
# vi: et sts=4 sw=4 ts=4
# Squashes together the parts of the app into the single script.
# (Adapted from the script that squashes App::Ack - see https://github.com/beyondgrep/ack3)
use warnings;
use strict;
my $code;
for my $arg (@ARGV) {
my $filename = $arg;
if ($arg =~ /::/) {
my $key = "$arg.pm";
$key =~ s{::}{/}g;
$filename = $INC{$key} or die "Can't find the file for $arg";
}
warn "Reading $filename\n";
open my $fh, '<', $filename or die "Can't open $filename: $!";
my $in_pod = 0;
my $in_ignore_section = 0;
while (<$fh>) {
if (/#.*:squash-ignore-start:$/) {
$in_ignore_section = 1;
next;
} elsif (/#.*:squash-ignore-end:$/) {
$in_ignore_section = 0;
next;
}
next if $in_ignore_section;
next if /#.*:squash-ignore-line:$/;
next if /^\s*1;$/;
if ($filename =~ /\.pm$/) {
# See if we're in module POD blocks
if (/^=(\w+)/) {
$in_pod = ($1 ne 'cut');
next;
}
elsif ($in_pod) {
next;
}
next if /^# vi:/;
}
# Remove Perl::Critic comments.
# I'd like to remove all comments, but this is a start
s{\s*##.+critic.*}{};
$code .= $_;
}
close $fh;
}
# Remove repeated newlines between paragraphs
$code =~ s/\n\n+/\n\n/gs;
print $code;
exit 0;