From 09e8113d7c05157cd54e16f820f6c7ce471d53b7 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 8 Apr 2015 01:09:31 -0400 Subject: Add some more scripts --- mkslackdesc | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 mkslackdesc (limited to 'mkslackdesc') diff --git a/mkslackdesc b/mkslackdesc new file mode 100755 index 0000000..4795a74 --- /dev/null +++ b/mkslackdesc @@ -0,0 +1,72 @@ +#!/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; -- cgit v1.2.3