cli: frontend page listing commandline parameters
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 6 Sep 2019 20:54:05 +0000 (22:54 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 1 Mar 2022 20:02:26 +0000 (21:02 +0100)
cli.plp [new file with mode: 0644]

diff --git a/cli.plp b/cli.plp
new file mode 100644 (file)
index 0000000..d8653e8
--- /dev/null
+++ b/cli.plp
@@ -0,0 +1,61 @@
+<(common.inc.plp)><:
+
+Html({
+       title => 'cli cheat sheet',
+       version => '1.0',
+       description => [],
+       keywords => [qw'
+       '],
+       data => ['data/cli.inc.pl'],
+});
+
+my $cmd = do 'data/cli.inc.pl'
+       or Abort("Error loading program data", 501, $@ // $!);
+:>
+<h1>CLI options</h1>
+
+<style>
+       tbody td {font-size:70%}
+</style>
+<:
+sub showoption {
+       my ($info, $char, $span) = @_;
+       my ($alias, $help) = @{ $info // [] };
+       printf '<td class="l%s"', $info ? 5 : 1;
+       print ' rowspan="2"' if $span;
+       print '>';
+       $info or return;
+       my ($title) = $alias =~ m{--([\w-]+=?)}
+               or return print $char;
+       $title =~ s/-\K/<wbr>/g;
+       $title =~ s/deref\Kerence/./;
+       print $title;
+}
+
+my @colchars = ('a'..'z', '?');
+print '<table class="ccmap"><col>';
+print qq'<colgroup span="$_">' for scalar @colchars;
+#say '</colgroup><col>';
+for my $section (qw{thead tfoot}) {
+       print "<$section><tr><th>↳";
+       print '<th>', EscapeHTML($_) for @colchars;
+       say '';
+}
+print '<tbody>';
+for my $name (sort keys %$cmd) {
+       my $row = $cmd->{$name};
+       print '<tr><th rowspan="2">', $name;
+       showoption($row->{$_}, $_, !$row->{uc $_}) for @colchars;
+       print "\n\t<tr>";
+       $row->{$_} and showoption($row->{$_}, $_) for map {uc} @colchars;
+}
+say '</table>';
+:>
+
+<div class="legend">
+       <table class="glyphs"><tr>
+       <td class="X l5">supported
+       <td class="X l1">unsupported
+       <td class="X l0 ex">alias
+       </table>
+</div>