From: Nicolas Boisselier Date: Fri, 1 Apr 2016 09:20:48 +0000 (+0200) Subject: ARGV for URL X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=c670b9e101d4c5d2c1533b7c07a8704615f350ac;p=nb.git ARGV for URL --- diff --git a/bin/ovh-api b/bin/ovh-api index fe10f61c..b7f9edf5 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -2,6 +2,7 @@ use strict; use warnings; use OvhApi; +use URI::Escape qw(uri_escape); use JSON; ################################################################################# # @@ -27,7 +28,10 @@ my ($NAME) = $0 =~ m,([^/]+)$,; my $VERBOSE = $main::VERBOSE = 1; my $DEBUG = $main::DEBUG = 0; -my %Opt; get_options(\%Opt); +my %Opt = ( + 'method' => 'GET', +); +get_options(\%Opt); help() unless @ARGV; $main::_DATA_ = undef; @@ -38,8 +42,7 @@ $main::_DATA_ = undef; ################################################################################# #use Data::Dumper; my @KEY = split(":",shift @ARGV); -my $URL = shift @ARGV; -my $METHOD = @ARGV ? shift(@ARGV) : 'GET'; +my $URL = @ARGV == 1 ? shift @ARGV : join('/',map{uri_escape($_)} @ARGV); # Auth if (@KEY==1) { @@ -51,7 +54,7 @@ if (@KEY==1) { my $o = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]); -my $response = $o->get(path=>$URL,method=>$METHOD); +my $response = $o->get(path=>$URL,method=>$Opt{method}); if (!$response) { die "$NAME: $URL failed!" @@ -167,6 +170,7 @@ https://api.ovh.com/console/#/domain =head1 OPTIONS + option[method|m] Method (default: GET) option[verbose|v+] Verbose mode: increase the verbosity level. option[debug+] Debug mode: increase the verbosity level. option[version|V] Print version (default: $VERSION)