summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-04-15 00:14:15 +0000
committerNorbert Preining <preining@logic.at>2017-04-15 00:14:15 +0000
commit789e1a4c5b3605f27c472dcaca9e1d458b9224ae (patch)
tree39e23955dd5e80e67b3cec8e35d3aac537fe9ad7 /Master
parent6d913fdc1bcc1409966c12270be70b8d8ee029ce (diff)
working version of tlmgr shell
git-svn-id: svn://tug.org/texlive/trunk@43797 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl101
-rw-r--r--Master/tlpkg/doc/tlmgr-shell.txt5
2 files changed, 90 insertions, 16 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index 88ad91a0160..50fd3298881 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -307,6 +307,9 @@ my %action_specification = (
"run-post" => 1,
"function" => \&action_search
},
+ "shell" => {
+ "function" => \&action_shell
+ },
"uninstall" => {
"options" => { "force" => 1 },
"run-post" => 0,
@@ -389,11 +392,6 @@ sub main {
TeXLive::TLUtils::process_logging_options();
- my $shellcheck = $ARGV[0];
- if (defined($shellcheck) && $shellcheck eq "shell") {
- exit(start_shell());
- }
-
GetOptions(\%opts, keys(%optarg)) or pod2usage(2);
$::debug_translation = 0;
@@ -6503,9 +6501,8 @@ sub check_on_writable {
###########
-# tlmgr shell codeS
-# IDEAS: use IO::Prompter
-sub start_shell {
+# tlmgr shell code
+sub action_shell {
my $protocol = 1;
my $prompt = "tlmgr> ";
@@ -6514,16 +6511,93 @@ sub start_shell {
print $prompt;
my $ans = <STDIN>;
chomp $ans;
- my ($cmd, @args) = split(' ', $ans);
+ my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans);
next if (!$cmd);
if ($cmd eq "protocol") {
print "protocol $protocol\n";
} elsif ($cmd eq "version") {
print give_version(), "\n";
} elsif ($cmd =~ m/^(quit|end|byebye)$/i) {
- return 0;
+ return $F_OK;
+ } elsif ($cmd eq "set") {
+ my $key = shift @args;
+ my $val = shift @args;
+ if (!$key) {
+ print "ERROR nothing to do\n";
+ next;
+ }
+ if ($key eq "repository") {
+ if (defined($val)) {
+ $location = $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);
+ # special cases
+ $::debug_translation = $opts{"debug-translation"};
+ $::machinereadable = $opts{"machine-readable"};
+ $::no_execute_actions = $opts{'no-execute-actions'};
+ } else {
+ print "$key = ", ($opts{$key} ? 1 : 0), "\n";
+ }
+ print "OK\n";
+ } else {
+ print "ERROR unknown key $key\n";
+ }
+ } elsif ($cmd eq "load") {
+ my $what = shift @args;
+ if ($what && $what eq "local") {
+ init_local_db();
+ print "OK\n";
+ } elsif ($what && $what eq "remote") {
+ init_tlmedia_or_die();
+ print "OK\n";
+ } else {
+ print "ERROR can only load 'local' or 'remote'\n";
+ }
+ } elsif ($cmd eq "save") {
+ $localtlpdb->save;
+ print "OK\n";
+ } elsif (defined($action_specification{$cmd})) {
+ # an action
+ if (!defined($action_specification{$cmd}{"function"})) {
+ print "ERROR action function not defined\n";
+ next;
+ }
+ # redo the option parsing
+ my %optarg;
+ if (defined($action_specification{$cmd}{'options'})) {
+ my %actopts = %{$action_specification{$cmd}{'options'}};
+ for my $k (keys %actopts) {
+ if ($actopts{$k} eq "1") {
+ $optarg{$k} = 1;
+ } else {
+ $optarg{"$k" . $actopts{$k}} = 1;
+ }
+ }
+ }
+ # save command line options for later restart, if necessary
+ @ARGV = @args;
+ my %savedopts = %opts;
+ %opts = ();
+ if (!GetOptions(\%opts, keys(%optarg))) {
+ print "ERROR unsupported arguments\n";
+ next;
+ }
+ my $ret = execute_action($cmd, @ARGV);
+ if ($ret & $F_ERROR) {
+ print "ERROR\n";
+ } elsif ($ret & $F_WARNING) {
+ print "OK\n";
+ } else {
+ print "OK\n";
+ }
+ %opts = %savedopts;
} else {
- print "not implemented by now\n";
+ print "ERROR unknown command\n";
}
}
}
@@ -7578,6 +7652,11 @@ C<tables> (unless they also contain the word C<table> on its own).
=back
+=head2 shell
+
+Starts the TeX Live Manager Shell.
+
+
=head2 uninstall
Uninstalls the entire TeX Live installation. Options:
diff --git a/Master/tlpkg/doc/tlmgr-shell.txt b/Master/tlpkg/doc/tlmgr-shell.txt
index 93384a53f4a..556265cc847 100644
--- a/Master/tlpkg/doc/tlmgr-shell.txt
+++ b/Master/tlpkg/doc/tlmgr-shell.txt
@@ -20,15 +20,10 @@ Commands:
* set
sets some variables not to be saved into the tlpdb
set repository ... == --repository
- set gui-lang LL == --gui-lang
set debug-translation 1 == --debug-translations
set machine-readable 1 == --machine-readable
set no-execute-actions 1 == --no-execute-actions
- set package-logfile .. == --package-logfile
- set persistent-downloads 0|1 == --(no-)persistent-downloads
- set pin-file ... == --pin-file
set require-verification 0|1 == --(no-)require-verification
- set usermode 1 == --usermode
set verify-downloads 0|1 == --(no-)verify-downloads
* quit|end|byebye