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

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


Revision: 43801
          http://tug.org/svn/texlive?view=revision&revision=43801
Author:   preining
Date:     2017-04-15 02:14:46 +0200 (Sat, 15 Apr 2017)
Log Message:
-----------
prompt rework, better set/get interaction

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-04-15 00:14:38 UTC (rev 43800)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-04-15 00:14:46 UTC (rev 43801)
@@ -6504,10 +6504,9 @@
 # tlmgr shell code
 sub action_shell {
   my $protocol = 1;
-  our $prompt = "tlmgr> ";
 
   eval { 
-    require MMMMIO::Prompter;
+    require IO::Prompter;
   };
   
   our $promptfunc;
@@ -6514,10 +6513,38 @@
   if ($@) {
     printf STDERR "Cannot find IO::Prompter module, reduced interactive functionality!\n";
     $promptfunc =  sub {
-      our $prompt;
-      print "$prompt";
+      my $default_prompt = "tlmgr>";
+      my $prompt = "";
+      my @options;
+      my @guarantee;
+      while (defined(my $arg = shift @_)) {
+        if ($arg =~ m/^-prompt$/) {
+          $prompt .= shift @_;
+        } elsif ($arg =~ m/^-style$/) {
+          # ignore style here
+          shift @_;
+        } elsif ($arg =~ m/^-menu$/) {
+          my $options = shift @_;
+          @options = @$options;
+        } elsif ($arg =~ m/^-guarantee$/) {
+          my $guarantee = shift @_;
+          @guarantee = @$guarantee;
+        } elsif ($arg =~ m/^-/) {
+          print "ERROR unsupported prompt command, please report: $arg!\n";
+        } else {
+          $prompt .= $arg;
+        }
+      }
+      $prompt = ($prompt ? $prompt : $default_prompt );
+      print "$prompt ";
+      if (@options) {
+        print "(", join(",", @options), ") ";
+      }
       my $ans = <STDIN>;
       chomp($ans);
+      if (@guarantee) {
+        # TODO TODO TODO
+      }
       return($ans);
     }
   } else {
@@ -6533,7 +6560,7 @@
   while (1) {
     # print $prompt;
     # my $ans = <STDIN>;
-    my $ans = do_prompt(-prompt => $prompt, -style => 'bold');
+    my $ans = do_prompt('tlmgr>', -style => 'bold');
     # chomp $ans;
     my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans);
     next if (!$cmd);
@@ -6553,8 +6580,12 @@
       if (!$key) {
         $key = do_prompt('Choose...', -menu => \@valid_keys, '>');
       }
+      if (!$key) {
+        print("ERROR missing argument for get\n");
+        next;
+      }
       if ($cmd eq "get" && defined($val)) {
-        print("ERROR no argument allowed for set\n");
+        print("ERROR no argument allowed for get\n");
         next;
       }
       if ($cmd eq "set" && !defined($val)) {
@@ -6568,7 +6599,11 @@
         if ($cmd eq "set") {
           $location = scalar($val);
         } else {
-          print "repository = $location\n";
+          if (defined($location)) {
+            print "repository = $location\n";
+          } else {
+            print "repository = <UNDEFINED>\n";
+          }
         }
         print "OK\n";
       } elsif ($key =~ m/^(debug-translation|machine-readable|no-execute-actions|require-verification|verify-downloads)$/i) {



More information about the tex-live-commits mailing list