#!/usr/bin/perl -w # mkslackdesc # Convert a README into a valid slack-desc. # Usage: mkslackdesc [input] # If input not given, reads the file README in the current dir. # To read from standard input, give - as the input file. # Output: a slack-desc, including the "how to edit" comments # and the "handy ruler" line. If the input text won't fit into # 11 72-characters lines, the output will not be a valid slack-desc, # and you'll get a warning to that effect. # Output is to slack-desc in the current directory, and is also echoed # to standard output. if(-e "slack-desc") { die "slack-desc already exists in current directory!\n"; } chomp ($pkg = `pwd`); $pkg =~ s,.*/,,; if(!@ARGV) { push @ARGV, "README"; } open my $f, ">slack-desc" or die $!; print "Writing to slack-desc:\n\n"; $ruler = <) { --$lines; chomp; my $outline = "$pkg:"; $outline .= " $_" if $_; $outline .= "\n"; print $outline; print $f $outline; } close $pipe; if($lines < 0) { warn "slack-desc is too long (should be 11 lines), output not valid\n"; } else { print "$pkg:\n" for 1..$lines; print $f "$pkg:\n" for 1..$lines; } close $f;