#! /bin/sh #! -*-perl-*- eval 'exec perl -x -wS $0 ${1+"$@"}' if 0; use strict; use warnings; use Text::Wrap; use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_version); use Pod::Usage; use Pod::Man; use File::Basename; use File::Spec; use File::Slurp; our $VERSION = '1.00'; my $progname = basename($0); my $progdescr = 'Format a slack-desc file'; my $outfile = 'slack-desc'; my $infile; my $url; GetOptions('h' => sub { pod2usage(-message => "$progname: $progdescr") }, 'help' => sub { pod2usage(-verbose => 2) }, 'usage' => sub { pod2usage(-verbose => 0) }, 'output|o=s' => \$outfile, 'file|f=s' => \$infile, 'url|u=s' => \$url ) or pod2usage(-message => "$progname: $progdescr", -exitstatus => 2, -output => \*STDERR); my $package = shift @ARGV || die "not enough arguments"; my $descr = shift @ARGV; die "too many arguments" if @ARGV; my $header = <catfile($outfile, 'slack-desc'); } open(STDOUT, '>', $outfile) or die "can't open output $outfile: $!"; print $header; print ' ' x length($package), $ruler, "\n"; my $text = read_file($infile ? $infile : \*STDIN) or die; $Text::Wrap::columns = $width; my @lines = split /\n/, fill("", "", $text); unshift @lines, ""; if ($descr) { unshift @lines, "$package ($descr)"; } else { print STDERR "warning: description missing\n"; unshift @lines, "$package"; } if (@lines > $nlines) { @lines = @lines[0..$nlines-1]; print STDERR "description truncated\n"; } else { if ($url) { if (@lines == $nlines) { print STDERR "no vacant lines for URL\n"; } elsif (@lines == $nlines - 1) { push @lines, "Homepage: $url"; } else { push @lines, "", "Homepage: $url"; } } push @lines, ("") x ($nlines - @lines) if (@lines < $nlines); } for (@lines) { print "$package:"; print " $_" if $_ ne ''; print "\n"; } =head1 NAME slackdesc - format a slack-desc file =head1 SYNOPSIS B [B<-f> I] [B<-o> I] [B<-u> I] [B<--file=>I] [B<--output=>I] [B<--url=>I] I [I] B B<-h> | B<--help> | B<--usage> | B<--version> =head1 DESCRIPTION Formats a B file for Slackware package I. Short package description can be given as the second argument. Keep it short enough to fit in a single line with the package name. Detailed description is read from I, or, if not given, from the standard input. The description will be formatted to fit nine lines left after the package name and short description followed by an empty line. This gives at most 657 characters (newlines included) left for the description. If the B<--url> (B<-u>) argument is given and there is at least one line left after formatting the description, an extra line saying C> will be added. =head1 OPTIONS =over 4 =item B<-f>, B<--file=>I Read description from the file I. =item B<-o>, B<--output=>I Write output to I, instead of C in the current working directory. If I is a name of an existing directory, the output file C will be created in that directory. =item B<-u>, B<--url=>I Supplies the URL of the package homepage. =item B<-h> Displays short usage help. =item B<--help> Displays detailed usage help. =item B<--usage> Displays a terse command line usage summary. =item B<--version> Prints program version. =back =head1 BUGS If you find any, please report it to Lgray@gnu.orgE>. =cut