summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPDB.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPDB.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm81
1 files changed, 60 insertions, 21 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index 68644527b6b..834920a8a48 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -500,39 +500,78 @@ sub options_as_json {
my $self = shift;
die("calling _as_json on virtual is not supported!") if ($self->is_virtual);
my $opts = $self->options;
+ my @opts;
for my $k (keys %TeXLive::TLConfig::TLPDBOptions) {
- if ($TeXLive::TLConfig::TLPDBOptions{$k}[0] =~ m/^n/) {
- $opts->{$k} += 0 if (exists($opts->{$k}));
- } elsif ($TeXLive::TLConfig::TLPDBOptions{$k}[0] eq "b") {
- $opts->{$k} = ($opts->{$k} ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False()) if (exists($opts->{$k}));
- } elsif ($k eq "location") {
+ my %foo;
+ $foo{'name'} = $k;
+ $foo{'tlmgrname'} = $TeXLive::TLConfig::TLPDBOptions{$k}[2];
+ $foo{'description'} = $TeXLive::TLConfig::TLPDBOptions{$k}[3];
+ $foo{'format'} = $TeXLive::TLConfig::TLPDBOptions{$k}[0];
+ $foo{'default'} = "$TeXLive::TLConfig::TLPDBOptions{$k}[1]";
+ # if ($TeXLive::TLConfig::TLPDBOptions{$k}[0] =~ m/^n/) {
+ # if (exists($opts->{$k})) {
+ # $foo{'value'} = $opts->{$k};
+ # $foo{'value'} += 0;
+ # }
+ # $foo{'default'} += 0;
+ # } elsif ($TeXLive::TLConfig::TLPDBOptions{$k}[0] eq "b") {
+ # if (exists($opts->{$k})) {
+ # $foo{'value'} = ($opts->{$k} ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False());
+ # }
+ # $foo{'default'} = ($foo{'default'} ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False());
+ # } elsif ($k eq "location") {
+ # my %def;
+ # $def{'main'} = $TeXLive::TLConfig::TLPDBOptions{$k}[1];
+ # $foo{'default'} = \%def;
+ # if (exists($opts->{$k})) {
+ # my %repos = TeXLive::TLUtils::repository_to_array($opts->{$k});
+ # $foo{'value'} = \%repos;
+ # }
+ # } elsif ($TeXLive::TLConfig::TLPDBOptions{$k}[0] eq "p") {
+ # # strings/path
+ # if (exists($opts->{$k})) {
+ # $foo{'value'} = $opts->{$k};
+ # }
+ # } else {
+
+ # TREAT ALL VALUES AS STRINGS, otherwise not parsable JSON
+ # treat as strings
if (exists($opts->{$k})) {
- my %foo = TeXLive::TLUtils::repository_to_array($opts->{$k});
- delete($opts->{$k});
- for my $u (keys %foo) {
- $opts->{$k}{$u} = $foo{$u};
- }
+ $foo{'value'} = $opts->{$k};
}
- }
- # the last else is plain strings, nothing to do
+ # }
+ push @opts, \%foo;
}
- return(TeXLive::TLUtils::encode_json($opts));
+ return(TeXLive::TLUtils::encode_json(\@opts));
}
sub settings_as_json {
my $self = shift;
die("calling _as_json on virtual is not supported!") if ($self->is_virtual);
my $sets = $self->settings;
+ my @json;
for my $k (keys %TeXLive::TLConfig::TLPDBSettings) {
- if ($TeXLive::TLConfig::TLPDBSettings{$k} eq "b") {
- $sets->{$k} = ($sets->{$k} ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False()) if (exists($sets->{$k}));
- } elsif ($TeXLive::TLConfig::TLPDBSettings{$k} eq "available_architectures") {
- delete($sets->{$k});
- @{$sets->{$k}} = $self->available_architectures;
- }
- # else are strings
+ my %foo;
+ $foo{'name'} = $k;
+ $foo{'type'} = $TeXLive::TLConfig::TLPDBSettings{$k}[0];
+ $foo{'description'} = $TeXLive::TLConfig::TLPDBSettings{$k}[1];
+ # if ($TeXLive::TLConfig::TLPDBSettings{$k}[0] eq "b") {
+ # if (exists($sets->{$k})) {
+ # $foo{'value'} = ($sets->{$k} ? TeXLive::TLUtils::True() : TeXLive::TLUtils::False());
+ # }
+ # } elsif ($TeXLive::TLConfig::TLPDBSettings{$k} eq "available_architectures") {
+ # if (exists($sets->{$k})) {
+ # my @lof = $self->available_architectures;
+ # $foo{'value'} = \@lof;
+ # }
+ # } else {
+ if (exists($sets->{$k})) {
+ $foo{'value'} = "$sets->{$k}";
+ }
+ # }
+ push @json, \%foo;
}
- return(TeXLive::TLUtils::encode_json($sets));
+ return(TeXLive::TLUtils::encode_json(\@json));
}
sub configs_as_json {