+ cleanup();
+
+ die $err if $err;
+
+} elsif ($clicmd eq 'compile-man') {
+
+ eval { compile_asciidoc('manvolnum'); };
+ my $err = $@;
+
+ cleanup();
+
+ die $err if $err;
+
+} elsif ($clicmd eq 'print-links') {
+
+ my $outfile;
+
+ GetOptions("outfile=s" => \$outfile,
+ "verbose" => \$verbose) or
+ die("Error in command line arguments\n");
+
+ scalar(@ARGV) == 0 or
+ die "too many arguments...\n";
+
+ my $data = get_links();
+
+ my $res = to_json($data, { pretty => 1, canonical => 1 } );
+
+ if (defined($outfile)) {
+ my $outfh = IO::File->new("$outfile", "w") or
+ die "unable to open temporary file '$outfile'\n";
+
+ print $outfh $res;
+
+ } else {
+
+ print $res;
+ }
+
+} elsif ($clicmd eq 'scan-extjs') {
+
+ GetOptions("verbose" => \$verbose) or
+ die("Error in command line arguments\n");
+
+ my $link_hash = {};
+ my $scanned_files = {};
+ while (my $filename = shift) {
+ die "got strange file name '$filename'\n"
+ if $filename !~ m/\.js$/;
+ next if $scanned_files->{$filename};
+
+ scan_extjs_file($filename, $link_hash);
+ $scanned_files->{$filename} = 1;
+ }
+
+ my $data = get_links();
+
+ my $res_data = {};
+
+ foreach my $blockid (keys %$link_hash) {
+ $res_data->{$blockid} = $data->{$blockid} || $online_help_links->{$blockid} ||
+ die "internal error - no data for '$blockid'";
+ }
+
+ my $data_str = to_json($res_data, { pretty => 1, canonical => 1 });
+ chomp $data_str;
+
+ print "var pveOnlineHelpInfo = ${data_str};\n";
+
+} elsif ($clicmd eq 'chapter-table') {
+
+ print '[width="100%",options="header"]' . "\n";
+ print "|====\n";
+ print "|Title|Link\n";
+
+ my $filelist = $fileinfo->{outfile}->{default};
+ foreach my $sourcefile (sort keys %$filelist) {
+ my $target = $filelist->{$sourcefile};
+ next if $target eq 'pve-admin-guide.html';
+ my $title = $fileinfo->{titles}->{default}->{$sourcefile} ||
+ die "not title for '$sourcefile'";
+ print "|$title|link:$target\[\]\n";
+ }
+
+ print "|====\n";
+
+} elsif ($clicmd =~ m/^man([158])page-table$/) {
+
+ my $section = $1;
+ print '[width="100%",cols="5*d",options="header"]' . "\n";
+ print "|====\n";
+ print "|Name 3+|Title|Link\n";
+
+ my $filelist = $fileinfo->{outfile}->{manvolnum};
+ foreach my $manpage (sort keys %$filelist) {
+ next if $section ne $fileinfo->{mansection}->{manvolnum}->{$manpage};
+ my $mantitle = $fileinfo->{titles}->{manvolnum}->{$manpage} ||
+ die "not manual title for '$manpage'";
+ my $title = $fileinfo->{titles}->{default}->{$manpage} ||
+ die "not title for '$manpage'";
+
+ # hack - remove command name prefix from titles
+ $title =~ s/^[a-z]+\s*-\s*//;
+
+ my $target = $filelist->{$manpage};
+ print "|$mantitle 3+|$title|link:$target.html\[$target\]\n";
+ }
+
+ print "|====\n";
+
+} else {
+
+ die "unknown command '$clicmd'\n";
+
+}