texlive[43800] Master: prompt etc etc
commits+preining at tug.org
commits+preining at tug.org
Sat Apr 15 02:14:39 CEST 2017
Revision: 43800
http://tug.org/svn/texlive?view=revision&revision=43800
Author: preining
Date: 2017-04-15 02:14:38 +0200 (Sat, 15 Apr 2017)
Log Message:
-----------
prompt etc etc
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:30 UTC (rev 43799)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl 2017-04-15 00:14:38 UTC (rev 43800)
@@ -6504,13 +6504,37 @@
# 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 @@
} 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 @@
}
} 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 {
Modified: trunk/Master/tlpkg/doc/tlmgr-shell.txt
===================================================================
--- trunk/Master/tlpkg/doc/tlmgr-shell.txt 2017-04-15 00:14:30 UTC (rev 43799)
+++ trunk/Master/tlpkg/doc/tlmgr-shell.txt 2017-04-15 00:14:38 UTC (rev 43800)
@@ -5,12 +5,8 @@
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
More information about the tex-live-commits
mailing list