summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-11-09 05:18:19 +0000
committerNorbert Preining <preining@logic.at>2017-11-09 05:18:19 +0000
commit594acd96f0625c0a981ef76b73a0d565fe4a43c7 (patch)
treed31b3ff0d50c92b599b7ab898357ab3002992b58 /Master
parentd81b3251ffa8a6dbaf19f21830805260d49543d5 (diff)
tlmgr shell: make global opts useable in subcmd and outside
git-svn-id: svn://tug.org/texlive/trunk@45728 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl70
1 files changed, 41 insertions, 29 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index bbf6739e7e5..a443fd6d11f 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -212,7 +212,7 @@ my %action_specification = (
"data" => "=s",
"all" => 1,
"list" => 1,
- "only-installed" => 1,
+ "only-installed" => 1
},
"run-post" => 0,
"function" => \&action_info
@@ -345,6 +345,29 @@ my %action_specification = (
"version" => { }, # handled separately
);
+my %globaloptions = (
+ "gui" => 1,
+ "gui-lang" => "=s",
+ "debug-json-timing" => 1,
+ "debug-translation" => 1,
+ "h|?" => 1,
+ "help" => 1,
+ "json" => 1,
+ "location|repository|repo" => "=s",
+ "machine-readable" => 1,
+ "no-execute-actions" => 1,
+ "package-logfile" => "=s",
+ "persistent-downloads" => "!",
+ "pause" => 1,
+ "pin-file" => "=s",
+ "print-platform|print-arch" => 1,
+ "usermode|user-mode" => 1,
+ "usertree|user-tree" => "=s",
+ "verify-downloads" => "!",
+ "require-verification" => "!",
+ "version" => 1,
+);
+
main() if $ismain;
@@ -353,29 +376,6 @@ main() if $ismain;
sub main {
my %options; # TL options from local tlpdb
- my %globaloptions = (
- "gui" => 1,
- "gui-lang" => "=s",
- "debug-json-timing" => 1,
- "debug-translation" => 1,
- "h|?" => 1,
- "help" => 1,
- "json" => 1,
- "location|repository|repo" => "=s",
- "machine-readable" => 1,
- "no-execute-actions" => 1,
- "package-logfile" => "=s",
- "persistent-downloads" => "!",
- "pause" => 1,
- "pin-file" => "=s",
- "print-platform|print-arch" => 1,
- "usermode|user-mode" => 1,
- "usertree|user-tree" => "=s",
- "verify-downloads" => "!",
- "require-verification" => "!",
- "version" => 1,
- );
-
my %optarg;
for my $k (keys %globaloptions) {
if ($globaloptions{$k} eq "1") {
@@ -6070,6 +6070,12 @@ sub action_key {
sub action_shell {
my $protocol = 1;
my $default_prompt = "tlmgr>";
+ # keys which can be set/get and are also settable via global cmdline opts
+ my @valid_bool_keys
+ = qw/debug-translation machine-readable no-execute-actions
+ require-verification verify-downloads json/;
+ my @valid_string_keys = qw/repository prompt/;
+ my @valid_keys = (@valid_bool_keys, @valid_string_keys);
# set auto flush unconditionally in action shell
$| = 1;
# we need to do an anonymous sub here otherwise the $default_prompt will get
@@ -6169,11 +6175,6 @@ sub action_shell {
exec("tlmgr", @::SAVEDARGV);
} elsif ($cmd =~ m/^(set|get)$/) {
- my @valid_bool_keys
- = qw/debug-translation machine-readable no-execute-actions
- require-verification verify-downloads/;
- my @valid_string_keys = qw/repository prompt/;
- my @valid_keys = (@valid_bool_keys, @valid_string_keys);
#
my $key = shift @args;
my $val = shift @args;
@@ -6267,6 +6268,13 @@ sub action_shell {
}
# redo the option parsing
my %optarg;
+ for my $k (@valid_bool_keys) {
+ if ($globaloptions{$k} eq "1") {
+ $optarg{$k} = 1;
+ } else {
+ $optarg{"$k" . $globaloptions{$k}} = 1;
+ }
+ }
if (defined($action_specification{$cmd}{'options'})) {
my %actopts = %{$action_specification{$cmd}{'options'}};
for my $k (keys %actopts) {
@@ -6281,6 +6289,10 @@ sub action_shell {
@ARGV = @args;
my %savedopts = %opts;
%opts = ();
+ # stuff global options back into the %opts array
+ for my $k (@valid_keys) {
+ $opts{$k} = $savedopts{$k} if (exists($savedopts{$k}));
+ }
if (!GetOptions(\%opts, keys(%optarg))) {
print "ERROR unsupported arguments\n";
next;