From 4299270b888777d238cab425a55014ae05b6f5d8 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 15 Apr 2017 00:14:46 +0000 Subject: prompt rework, better set/get interaction git-svn-id: svn://tug.org/texlive/trunk@43801 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/tlmgr.pl | 49 +++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 56133e0df85..4318029d48a 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -6504,20 +6504,47 @@ sub check_on_writable { # tlmgr shell code sub action_shell { my $protocol = 1; - our $prompt = "tlmgr> "; eval { - require MMMMIO::Prompter; + require IO::Prompter; }; our $promptfunc; 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 = ; chomp($ans); + if (@guarantee) { + # TODO TODO TODO + } return($ans); } } else { @@ -6533,7 +6560,7 @@ sub action_shell { while (1) { # print $prompt; # my $ans = ; - 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 @@ sub action_shell { 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 @@ sub action_shell { if ($cmd eq "set") { $location = scalar($val); } else { - print "repository = $location\n"; + if (defined($location)) { + print "repository = $location\n"; + } else { + print "repository = \n"; + } } print "OK\n"; } elsif ($key =~ m/^(debug-translation|machine-readable|no-execute-actions|require-verification|verify-downloads)$/i) { -- cgit v1.2.3