diff options
author | Norbert Preining <preining@logic.at> | 2017-04-15 00:14:38 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-04-15 00:14:38 +0000 |
commit | 974bf06b1ce6cad9ff152764f4d78b6f16c58cd1 (patch) | |
tree | 9d4d0039538d9f8ea8e1e9c1a1850a1f4a3f701d /Master/texmf-dist/scripts | |
parent | cd1f2edf9fd5e822f2b06be0ba4cac051339c89b (diff) |
prompt etc etc
git-svn-id: svn://tug.org/texlive/trunk@43800 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index ec780c45b5f..56133e0df85 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -6504,13 +6504,37 @@ sub check_on_writable { # tlmgr shell code sub action_shell { my $protocol = 1; - my $prompt = "tlmgr> "; + our $prompt = "tlmgr> "; + + eval { + require MMMMIO::Prompter; + }; + + our $promptfunc; + if ($@) { + printf STDERR "Cannot find IO::Prompter module, reduced interactive functionality!\n"; + $promptfunc = sub { + our $prompt; + print "$prompt"; + my $ans = <STDIN>; + chomp($ans); + return($ans); + } + } else { + $promptfunc = \&IO::Prompter::prompt; + } + sub do_prompt { + our $promptfunc; + my $foo = $promptfunc->(@_); + return($foo); + } print "protocol $protocol\n"; while (1) { - print $prompt; - my $ans = <STDIN>; - chomp $ans; + # print $prompt; + # my $ans = <STDIN>; + my $ans = do_prompt(-prompt => $prompt, -style => 'bold'); + # chomp $ans; my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans); next if (!$cmd); if ($cmd eq "protocol") { @@ -6522,23 +6546,34 @@ sub action_shell { } elsif ($cmd eq "setup-location") { my $dest = shift @args; print "ERROR not implemented: $cmd\n"; - } elsif ($cmd eq "set") { + } elsif ($cmd =~ m/^(set|get)$/) { + my @valid_keys = qw/repository debug-translation machine-readable no-execute-actions require-verification verify-downloads/; my $key = shift @args; my $val = shift @args; if (!$key) { - print "ERROR nothing to do\n"; + $key = do_prompt('Choose...', -menu => \@valid_keys, '>'); + } + if ($cmd eq "get" && defined($val)) { + print("ERROR no argument allowed for set\n"); next; } + if ($cmd eq "set" && !defined($val)) { + if ($key eq "repository") { + $val = do_prompt('Enter repository:'); + } else { + $val = do_prompt('Enter 1 for on, 0 for off:', -guarantee => [0,1]); + } + } if ($key eq "repository") { - if (defined($val)) { - $location = $val; + if ($cmd eq "set") { + $location = scalar($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); + if ($cmd eq "set") { + $opts{$key} = ($val eq "1" ? 1 : 0); ### THIS DOES NOT WORK??? TODO TODO # special cases $::debug_translation = $opts{"debug-translation"}; $::machinereadable = $opts{"machine-readable"}; @@ -6552,10 +6587,13 @@ sub action_shell { } } elsif ($cmd eq "load") { my $what = shift @args; - if ($what && $what eq "local") { + if (!defined($what)) { + $what = do_prompt("Choose...", -menu => ['local', 'remote'], '>'); + } + if ($what eq "local") { init_local_db(); print "OK\n"; - } elsif ($what && $what eq "remote") { + } elsif ($what eq "remote") { init_tlmedia_or_die(); print "OK\n"; } else { |