aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-04-18 07:11:37 +0000
committerTom Feist <shabble@metavore.org>2011-04-18 07:11:37 +0000
commit9d391a4fc542b559e28cb3b343a9e725a87691e5 (patch)
tree367e89441c9f9b67136e083f5731e58191ab0cef
parentido-mode/ido_switcher: minor comment/ cleanup (diff)
downloadirssi-scripts-9d391a4fc542b559e28cb3b343a9e725a87691e5.tar.gz
irssi-scripts-9d391a4fc542b559e28cb3b343a9e725a87691e5.zip
readme_generator: made it actually work.
-rw-r--r--readme_generator.pl22
1 files changed, 13 insertions, 9 deletions
diff --git a/readme_generator.pl b/readme_generator.pl
index 20e7312..5a997e4 100644
--- a/readme_generator.pl
+++ b/readme_generator.pl
@@ -12,8 +12,11 @@ use warnings;
use File::Find;
use File::Spec;
use Pod::Markdown;
+use feature qw/say/;
+use Cwd;
+my @dirs = map { File::Spec->catdir(getcwd(), $_) } @ARGV;
-my @dirs = @ARGV // '.';
+die unless @dirs;
find(\&wanted, @dirs);
@@ -22,30 +25,31 @@ sub wanted {
return unless $file =~ m/\.pl$/;
_err("processing file: $path");
+ read_input_file($dir, $file);
}
sub read_input_file {
- my ($path, $filename) = @_;
+ my ($dir, $filename) = @_;
- my $filepath = File::Spec->catfile($path, $filename);
+ my $filepath = File::Spec->catfile($dir, $filename);
- open my $rfh, '<', $filepath or die "Couldn't open $filepath for output: $!";
+ open my $rfh, '<', $filepath or die "Couldn't open $filepath for input: $!";
_err("reading $filepath");
my $parser = Pod::Markdown->new;
- $parser->parse($rfh);
+ $parser->parse_from_filehandle($rfh);
close $rfh;
- create_output_file($path, 'README.md', $parser);
+ create_output_file($dir, 'README.md', $parser);
}
sub create_output_file {
- my ($path, $filename, $parser) = @_;
+ my ($dir, $filename, $parser) = @_;
- my $filepath = File::Spec->catfile($path, $filename);
+ my $filepath = File::Spec->catfile($dir, $filename);
_err("Writing to $filepath");
@@ -57,5 +61,5 @@ sub create_output_file {
sub _err {
my ($msg, @args) = @_;
my $str = sprintf($msg, @args);
- print STDERR $str;
+ say STDERR $str;
}