2008-03-08 06:58:21 -05:00
|
|
|
#! /usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my ($elinks, $option) = @ARGV;
|
|
|
|
|
|
|
|
if ($option =~ /command/) {
|
|
|
|
open my $pipe, "-|", $elinks, "--long-help" or die;
|
|
|
|
my $version = <$pipe>;
|
|
|
|
chomp $version;
|
|
|
|
$version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
|
|
|
|
my $blank = 1;
|
|
|
|
while (<$pipe>) {
|
|
|
|
if (/^ {4}(-.*?) *$/) {
|
|
|
|
# ' -anonymous [0|1] (default: 0)'
|
|
|
|
# ' -config-dir <str> (default: "")'
|
|
|
|
$_ = $1;
|
|
|
|
s/ {2,}/ /g;
|
|
|
|
print "${_}::\n";
|
|
|
|
} elsif (/^ {12}\t(-eval .*)$/) {
|
|
|
|
print "\n\t$1\n";
|
|
|
|
} elsif (/^ {12}\t(\w+\(.*\)) +: (.*)$/) {
|
|
|
|
# ' openURL(URL, new-tab) : open URL in new tab'
|
|
|
|
print "\t- `$1`: $2\n";
|
|
|
|
} elsif (/^ {12}\t(\d+) (means .+)$/) {
|
|
|
|
# ' 0 means only show serious errors'
|
|
|
|
print "\t- $1:\t$2\n";
|
|
|
|
} elsif (s/^ {12}//) {
|
|
|
|
s/'([^']+)'/\\'$1\\'/g;
|
|
|
|
s((~/\.elinks|-dump|-default-mime-type|text/html|-touch-files|-no-connect|-session-ring))(`$1`)g;
|
|
|
|
s/(ELinks|HOME)/'$1'/g;
|
|
|
|
print "\t$_";
|
|
|
|
} else {
|
|
|
|
print "\n" unless $blank;
|
|
|
|
$blank = 2;
|
|
|
|
}
|
|
|
|
$blank = ($blank == 2);
|
|
|
|
}
|
|
|
|
print "Generated using output from ELinks version $version.\n";
|
|
|
|
} elsif ($option =~ /config/) {
|
|
|
|
open my $pipe, "-|", $elinks, "--config-help" or die;
|
|
|
|
my $version = <$pipe>;
|
|
|
|
chomp $version;
|
|
|
|
$version =~ s/^ELinks ([-.\w]+).*$/$1/ or die "unusual version: $version";
|
|
|
|
my $blank = 1;
|
|
|
|
my $continued = 0;
|
|
|
|
while (<$pipe>) {
|
|
|
|
if (/^ {2}[^ ].*: \(([-.\w]+)\)$/) {
|
|
|
|
# ' Active link: (document.browse.links.active_link)'
|
|
|
|
print "$1::\n";
|
|
|
|
} elsif (/^ {4}([^ ].*?)$/) {
|
|
|
|
# ' bookmarks.file_format <num> (default: 0)'
|
|
|
|
print "$1::\n";
|
|
|
|
} elsif (/^ {12,}$/) {
|
|
|
|
print "+\n";
|
|
|
|
$continued = 1;
|
|
|
|
} elsif (s/^ {12,}//) {
|
|
|
|
# escape things that might look like AsciiDoc markup
|
|
|
|
s/'(.*?)'/\\'$1\\'/g;
|
|
|
|
s/\{(.*?)\}/\\{$1\\}/g;
|
|
|
|
# add the actual AsciiDoc markup
|
|
|
|
s/(ELinks|WWW_HOME)/'$1'/g;
|
|
|
|
s((~/\.elinks))(`$1`)g;
|
|
|
|
if (/^(-?\d[-+\d]*?) +(.*)$/) {
|
|
|
|
# ' 1+ is use cookie's expiration date, but limit age to the given'
|
|
|
|
print "\t- $1:\t$2\n";
|
|
|
|
} elsif ($continued) {
|
|
|
|
print "$_";
|
|
|
|
} else {
|
|
|
|
print "\t$_";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print "\n" unless $blank;
|
|
|
|
$blank = 2;
|
|
|
|
$continued = 0;
|
|
|
|
}
|
|
|
|
$blank = ($blank == 2);
|
|
|
|
}
|
|
|
|
print "Generated using output from ELinks version $version.\n";
|
|
|
|
} else {
|
|
|
|
die "usage: $0 ELINKS-EXECUTABLE option-command.txt\n"
|
|
|
|
. " or: $0 ELINKS-EXECUTABLE option-config.txt\n";
|
2005-09-15 09:58:31 -04:00
|
|
|
}
|