RetroZilla/extensions/xmlterm/scripts/xrpchelp
2015-10-20 23:03:22 -04:00

35 lines
1.2 KiB
Perl

#!/usr/bin/perl
# Usage: xrpchelp <server-URL> [<method-name>]
use Frontier::Client;
die "Usage: xrpchelp <server-URL> [<method-name>]\n"
unless (@ARGV == 1) or (@ARGV == 2);
my $url = shift @ARGV; # XML-RPC server URL
$server = Frontier::Client->new( 'url' => $url, 'debug' => 0 );
my $cookie = $ENV{LTERM_COOKIE}; # Cookie for security
print "\e{S$cookie\012"; # Escape sequence for start of HTML
if (@ARGV) { # Print help string for method
print $server->call("system.methodHelp", @ARGV), "\n"; # Print method help
} else { # List all method names
my $list = $server->call("system.listMethods", @ARGV); # Get method names
print "<OL>\n"; # Ordered list start tag
foreach $method (@$list) { # For each method name, add list element
print qq%<LI><SPAN CLASS='textlink' onClick="return HandleEvent(event,
'click','sendln',-\#,'xrpchelp $url $method')">$method</SPAN>\n%;
}
print "</OL>\n"; # Ordered list end tag
}
print "\000"; # Escape sequence for end of HTML