Commit 899aa868 authored by Guillaume Huard's avatar Guillaume Huard
Browse files

New option 'path'

parent e6b8a61c
......@@ -5,11 +5,13 @@ use File::Slurp;
use Getopt::Long qw(:config bundling);
my $url = 'https://moodle.caseine.org';
my $path = 'webservice/rest/server.php';
my $debug=0;
my $json=0;
my $vplid=$ENV{'VPLADMIN_ID'};
my $token=$ENV{'VPLADMIN_TOKEN'};
$url=$ENV{'VPLADMIN_SERVER'} if exists($ENV{'VPLADMIN_SERVER'});
$path=$ENV{'VPLADMIN_PATH'} if exists($ENV{'VPLADMIN_PATH'});
sub help();
sub failure($);
......@@ -75,10 +77,11 @@ my @commands = keys(%handlers);
sub help() {
print <<"END";
usage :
$0 [ --help ] [ --json ] [ --server url ] [ --token value ] [ --id value ] command [ arguments ]
$0 [ --help ] [ --json ] [ --server url ] [ --path path ] [ --token value ] [ --id value ] command [ arguments ]
Pushes data to caseine, where :
- server is the url at which one can find the 'webservice/rest/server.php' service (by default it is https://moodle.caseine.org or VPLADMIN_SERVER if defined)
- server is the url of the server hosting the webservice (by default it is 'https://moodle.caseine.org' or VPLADMIN_SERVER if defined)
- path is the path on the server at which one can find the webservice (by default it is 'webservice/rest/server.php' or VPLADMIN_PATH if defined)
- token is the personnal token associated to the user of this script (by default, the value of the VPLADMIN_TOKEN environment variable)
- id is the id number of the involved VPL (by default, the value of the VPLADMIN_ID environment variable)
- the output is in JSON format is the --json option is given
......@@ -100,6 +103,7 @@ sub failure($) {
GetOptions('help|h|?' => \&help,
'server|s=s' => \$url,
'path|p=s' => \$path,
'id|i=s' => \$vplid,
'token|t=s' => \$token,
'debug|d' => \$debug,
......@@ -107,11 +111,11 @@ GetOptions('help|h|?' => \&help,
);
#failure "Missing command" if scalar(@ARGV) == 0;
debug "SERVER = $url, VPLID = $vplid, TOKEN = $token, ARGS = @ARGV\n";
debug "SERVER = $url, PATH = $path, VPLID = $vplid, TOKEN = $token, ARGS = @ARGV\n";
$url .= '/'.$path;
failure "Missing token" unless defined($token);
failure "Missing VPL ID" unless defined($vplid);
$url .= '/webservice/rest/server.php';
my $command = shift @ARGV;
my $content = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment