#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use Net::Async::SPORE::Loader;

GetOptions(
	"spec|s=s" => \my $spec,
) or die "invalid options";

my $api = Net::Async::SPORE::Loader->new_from_file(
	$spec,
);

my $method = shift @ARGV;
my %args = map { split /=/, $_, 2 } @ARGV;

binmode STDOUT, ':encoding(UTF-8)';
my $json = JSON::MaybeXS->new(
	pretty => 1
);
eval {
	my $rslt = $api->$method(
		%args
	)->get;
	warn "rslt = $rslt\n";
	print $json->encode($rslt);
} or do {
	warn "Failed to execute $method - $@\n";
};

