Re: TL2012 and paper config
On Sa, 03 Mär 2012, Frank Küster wrote:
> > Do you want me to create some mini-perl program that does only the
> > paper stuff? Or is it enough clear what should happen?
>
> I must admit: I am very much away from Perl programming currently.
> Either a mini program, or at least a mini-mini-program that shows how to
> call one specific function and I can try the commandline parsing and the
> rest of functions.
Attached
tl-paper list <program>
tl-paper status
tl-paper set <program> <newpaper>
tl-paper set all <a4|letter>
I guess from here it is easy to change to style of arguments ;-)
Best wishes
Norbert
------------------------------------------------------------------------
Norbert Preining preining@{jaist.ac.jp, logic.at, debian.org}
JAIST, Japan TeX Live & Debian Developer
DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
------------------------------------------------------------------------
The suit into which the man's body had been stuffed looked
as if it's only purpose in life was to demonstrate how
difficult it was to get this sort of body into a suit.
--- Douglas Adams, The Hitchhikers Guide to the Galaxy
#!/usr/bin/env perl
BEGIN {
$^W = 1;
chomp ($mydir = `dirname $0`);
unshift (@INC, "/usr/share/texlive/tlpkg");
# for TESTING ONLY
unshift (@INC, "/src/TeX/texlive-svn/Master/tlpkg");
}
$^W = 1;
use strict;
use Cwd qw/abs_path/;
use Pod::Usage;
use Getopt::Long qw(:config no_autoabbrev permute);
use TeXLive::TLPaper;
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
&main();
sub main {
# the script always runs in sys mode
chomp(my $texmfsysconfig = `kpsewhich -var-value=TEXMFSYSCONFIG`);
chomp(my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`);
$ENV{"TEXMFCONFIG"} = $texmfsysconfig;
$ENV{"TEXMFVAR"} = $texmfsysvar;
my $action = shift @ARGV;
if ($action =~ m/^status$/i) { # "tl-paper status" shows the current settings
TeXLive::TLPaper::paper_all($texmfsysconfig,undef);
} elsif ($action =~ m/^list$/i) { # "tl-paper list prg" lists options for prg
my $prg = shift @ARGV;
if (!$prg) {
usage();
exit 1;
}
# the following actually also *reads* the configuration and returns
# a list where the first item is the one selected.
my ($current_paper, @other_options) = TeXLive::TLPaper::get_paper_list($prg);
for my $i ($current_paper, sort @other_options) {
print "$i\n";
}
# for simply getting the list of supported paper sizes without reading
# anything, one can use:
# my @paper_options = keys(%{${prg}_papersize});
} elsif ($action =~ m/^set$/i) { # "tl-paper set <prg|all> <paper>" sets paper
my $prg = shift @ARGV;
my $newpaper = shift @ARGV;
if ($prg !~ m/^(xdvi|pdftex|dvips|dvipdfmx|dvipdfm|context|all)$/i) {
usage();
exit 1;
}
if ($prg =~ m/^all$/i) {
if ($newpaper !~ /^(a4|letter)$/) {
# we cannot deal with that for now, only a4|letter supported for
# all programs
usage();
exit 1;
}
TeXLive::TLPaper::paper_all($texmfsysconfig,$newpaper);
} else {
TeXLive::TLPaper::do_paper($prg,$texmfsysconfig,$newpaper);
}
} else {
usage();
exit 1;
}
exit 0;
}
sub usage {
print STDERR "
tl-paper: inquire and set paper settings for various programs in the TeX World.
usage:
tl-paper list <program>
tl-paper status
tl-paper set <program> <newpaper>
tl-paper set all <a4|letter>
";
}
### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #
Reply to: