summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl62
-rw-r--r--Master/tlpkg/doc/tlmgr-shell.txt4
2 files changed, 50 insertions, 16 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 {
diff --git a/Master/tlpkg/doc/tlmgr-shell.txt b/Master/tlpkg/doc/tlmgr-shell.txt
index e48ecd1fd8f..7c2491f4291 100644
--- a/Master/tlpkg/doc/tlmgr-shell.txt
+++ b/Master/tlpkg/doc/tlmgr-shell.txt
@@ -5,12 +5,8 @@ to be written
TODO & BUGS
------------
-* print() on closed filehandle PACKAGELOG at /home/norbert/tl/2016/bin/x86_64-linux/tlmgr line 6358.
- on all updates (--self, --all)
-
* need to restart after self update
-
* installation from shell - command
init-location