texlive[43797] Master: working version of tlmgr shell

commits+preining at tug.org commits+preining at tug.org
Sat Apr 15 02:14:15 CEST 2017


Revision: 43797
          http://tug.org/svn/texlive?view=revision&revision=43797
Author:   preining
Date:     2017-04-15 02:14:15 +0200 (Sat, 15 Apr 2017)
Log Message:
-----------
working version of tlmgr shell

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
    trunk/Master/tlpkg/doc/tlmgr-shell.txt

Modified: trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-04-15 00:14:07 UTC (rev 43796)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-04-15 00:14:15 UTC (rev 43797)
@@ -307,6 +307,9 @@
     "run-post" => 1,
     "function" => \&action_search
   },
+  "shell" => {
+    "function" => \&action_shell
+  },
   "uninstall" => {
     "options"  => { "force" => 1 },
     "run-post" => 0,
@@ -389,11 +392,6 @@
 
   TeXLive::TLUtils::process_logging_options();
 
-  my $shellcheck = $ARGV[0];
-  if (defined($shellcheck) && $shellcheck eq "shell") {
-    exit(start_shell());
-  }
-
   GetOptions(\%opts, keys(%optarg)) or pod2usage(2);
 
   $::debug_translation = 0;
@@ -6503,9 +6501,8 @@
 
 
 ###########
-# tlmgr shell codeS
-# IDEAS: use IO::Prompter
-sub start_shell {
+# tlmgr shell code
+sub action_shell {
   my $protocol = 1;
   my $prompt = "tlmgr> ";
 
@@ -6514,7 +6511,7 @@
     print $prompt;
     my $ans = <STDIN>;
     chomp $ans;
-    my ($cmd, @args) = split(' ', $ans);
+    my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans);
     next if (!$cmd);
     if ($cmd eq "protocol") {
       print "protocol $protocol\n";
@@ -6521,9 +6518,86 @@
     } elsif ($cmd eq "version") {
       print give_version(), "\n";
     } elsif ($cmd =~ m/^(quit|end|byebye)$/i) {
-      return 0;
+      return $F_OK;
+    } elsif ($cmd eq "set") {
+      my $key = shift @args;
+      my $val = shift @args;
+      if (!$key) {
+        print "ERROR nothing to do\n";
+        next;
+      }
+      if ($key eq "repository") {
+        if (defined($val)) {
+          $location = $val;
+        } else {
+          print "repository = $location\n";
+        }
+        print "OK\n";
+      } elsif ($key =~ m/^(debug-translation|machine-readable|no-execute-actions|require-verification|verify-downloads)$/i) {
+        if (defined($val)) {
+          $opts{$key} = ($val ? 1 : 0);
+          # special cases
+          $::debug_translation = $opts{"debug-translation"};
+          $::machinereadable = $opts{"machine-readable"};
+          $::no_execute_actions = $opts{'no-execute-actions'};
+        } else {
+          print "$key = ", ($opts{$key} ? 1 : 0), "\n";
+        }
+        print "OK\n";
+      } else {
+        print "ERROR unknown key $key\n";
+      }
+    } elsif ($cmd eq "load") {
+      my $what = shift @args;
+      if ($what && $what eq "local") {
+        init_local_db();
+        print "OK\n";
+      } elsif ($what && $what eq "remote") {
+        init_tlmedia_or_die();
+        print "OK\n";
+      } else {
+        print "ERROR can only load 'local' or 'remote'\n";
+      }
+    } elsif ($cmd eq "save") {
+      $localtlpdb->save;
+      print "OK\n";
+    } elsif (defined($action_specification{$cmd})) {
+      # an action
+      if (!defined($action_specification{$cmd}{"function"})) {
+        print "ERROR action function not defined\n";
+        next;
+      }
+      # redo the option parsing
+      my %optarg;
+      if (defined($action_specification{$cmd}{'options'})) {
+        my %actopts = %{$action_specification{$cmd}{'options'}};
+        for my $k (keys %actopts) {
+          if ($actopts{$k} eq "1") {
+            $optarg{$k} = 1;
+          } else {
+            $optarg{"$k" . $actopts{$k}} = 1;
+          }
+        }
+      }
+      # save command line options for later restart, if necessary
+      @ARGV = @args;
+      my %savedopts = %opts;
+      %opts = ();
+      if (!GetOptions(\%opts, keys(%optarg))) {
+        print "ERROR unsupported arguments\n";
+        next;
+      }
+      my $ret = execute_action($cmd, @ARGV);
+      if ($ret & $F_ERROR) {
+        print "ERROR\n";
+      } elsif ($ret & $F_WARNING) {
+        print "OK\n";
+      } else {
+        print "OK\n";
+      }
+      %opts = %savedopts;
     } else {
-      print "not implemented by now\n";
+      print "ERROR unknown command\n";
     }
   }
 }
@@ -7578,6 +7652,11 @@
 
 =back
 
+=head2 shell
+
+Starts the TeX Live Manager Shell. 
+
+
 =head2 uninstall
 
 Uninstalls the entire TeX Live installation.  Options:

Modified: trunk/Master/tlpkg/doc/tlmgr-shell.txt
===================================================================
--- trunk/Master/tlpkg/doc/tlmgr-shell.txt	2017-04-15 00:14:07 UTC (rev 43796)
+++ trunk/Master/tlpkg/doc/tlmgr-shell.txt	2017-04-15 00:14:15 UTC (rev 43797)
@@ -20,15 +20,10 @@
 * set
   sets some variables not to be saved into the tlpdb
 	set repository ...	== --repository
-	set gui-lang LL		== --gui-lang
 	set debug-translation 1	== --debug-translations
 	set machine-readable 1	== --machine-readable
 	set no-execute-actions 1 == --no-execute-actions
-	set package-logfile ..	== --package-logfile
-	set persistent-downloads 0|1 == --(no-)persistent-downloads
-	set pin-file ...	== --pin-file
 	set require-verification 0|1 == --(no-)require-verification
-	set usermode 1		== --usermode
 	set verify-downloads 0|1 == --(no-)verify-downloads
 
 * quit|end|byebye



More information about the tex-live-commits mailing list