diff options
author | Norbert Preining <preining@logic.at> | 2017-11-09 04:44:14 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-11-09 04:44:14 +0000 |
commit | 57ae160a8956fedde1ce1e1b4e076eeec8c24105 (patch) | |
tree | e4a750318762fcb7854351a3241052132f3c8a05 /Master/texmf-dist/scripts | |
parent | cbf9f280adfde6df7c633470a8ccd9521d53c9d4 (diff) |
move JSON loading to the front, remove from other places
git-svn-id: svn://tug.org/texlive/trunk@45726 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 2081493933a..bbf6739e7e5 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -578,6 +578,19 @@ for the full story.\n"; tldie("$prg: Try --help if you need it.\n"); } + if ($opts{'json'}) { + eval { require TeXLive::JSON; }; + if ($@) { + # that didn't work out, give some usefull error message and stop + if ($^O =~ /^MSWin/i) { + require Win32; + my $msg = "Cannot load JSON, that should not happen as we ship it!\n(Error message: $@)\nStopping here.\n"; + Win32::MsgBox($msg, 1|Win32::MB_ICONSTOP(), "Warning"); + } + tldie("Cannot load JSON module, this should not happen, please report!\n"); + } + } + # # the main tree we will be working on $::maintree = $Master; @@ -1419,17 +1432,6 @@ sub action_info { delete($opts{'data'}); } if ($opts{'json'}) { - eval { require TeXLive::JSON; }; - if ($@) { - # that didn't work out, give some usefull error message and stop - if ($^O =~ /^MSWin/i) { - # that should not happen, we are shipping Tk!! - require Win32; - my $msg = "Cannot load JSON, that should not happen as we ship it!\n(Error message: $@)\nStopping here.\n"; - Win32::MsgBox($msg, 1|Win32::MB_ICONSTOP(), "Warning"); - } - tldie("Cannot load JSON module, this should not happen, please report!\n"); - } $fmt = 'json'; # the 1 is the silent mode! init_tlmedia_or_die(1); @@ -1838,21 +1840,24 @@ sub action_restore { if ($mode eq "json") { $jsonkeys{'rev'} = "$rs"; $jsonkeys{'date'} = $dstr; - push @outarr, TeXLive::TLUtils::simple_hash_to_json(\%jsonkeys); + push @outarr, \%jsonkeys; } else { push @outarr, "$rs ($dstr)"; } } - join(($mode eq "json" ? "," : " "), @outarr); + if ($mode eq "json") { + return @outarr; + } else { + return ( join(" ", @outarr)); + } } # end sub if (!defined($pkg)) { if (keys %backups) { if ($opts{'json'}) { - my $str = "["; - $str .= join(",", map { report_backup_revdate($_, "json", %{$backups{$_}}) } keys %backups); - $str .= "]\n"; - print $str; + my @bla = map { report_backup_revdate($_, "json", %{$backups{$_}}) } keys %backups; + my $str = JSON::encode_json(\@bla); + print "$str\n"; } else { print "Available backups:\n"; foreach my $p (sort keys %backups) { @@ -1868,10 +1873,9 @@ sub action_restore { } if (!defined($rev)) { if ($opts{'json'}) { - my $str = "["; - $str .= report_backup_revdate($pkg, "json", %{$backups{$pkg}}); - $str .= "]\n"; - print $str; + my @bla = report_backup_revdate($pkg, "json", %{$backups{$pkg}}); + my $str = JSON::encode_json(\@bla); + print "$str\n"; } else { print "Available backups for $pkg: "; print(report_backup_revdate($pkg, "text", %{$backups{$pkg}})); |