texlive[45728] Master/texmf-dist/scripts/texlive/tlmgr.pl: tlmgr

commits+preining at tug.org commits+preining at tug.org
Thu Nov 9 06:18:19 CET 2017


Revision: 45728
          http://tug.org/svn/texlive?view=revision&revision=45728
Author:   preining
Date:     2017-11-09 06:18:19 +0100 (Thu, 09 Nov 2017)
Log Message:
-----------
tlmgr shell: make global opts useable in subcmd and outside

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl

Modified: trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-11-09 04:44:22 UTC (rev 45727)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-11-09 05:18:19 UTC (rev 45728)
@@ -212,7 +212,7 @@
       "data" => "=s",
       "all" => 1,
       "list" => 1, 
-      "only-installed" => 1,
+      "only-installed" => 1
     },
     "run-post" => 0,
     "function" => \&action_info
@@ -345,6 +345,29 @@
   "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 @@
 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_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 @@
       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 @@
       }
       # 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 @@
       @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;



More information about the tex-live-commits mailing list