]> git.nbdom.net Git - nb.git/commitdiff
ARGV for URL
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 1 Apr 2016 09:20:48 +0000 (11:20 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 1 Apr 2016 09:20:48 +0000 (11:20 +0200)
bin/ovh-api

index fe10f61c0a7a1a490ca0b292750be3f1869d07b0..b7f9edf5366463ef465cf57f601fd70f51dad222 100755 (executable)
@@ -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)