]> git.proxmox.com Git - pve-client.git/blame - pveclient
improve usage text
[pve-client.git] / pveclient
CommitLineData
29505e2c
DM
1#!/usr/bin/perl
2
3use strict;
4use warnings;
565bbc73 5use lib '/usr/share/pve-client';
c5111270 6use lib '.';
29505e2c
DM
7use Data::Dumper;
8
a04fd959 9use PVE::JSONSchema;
565bbc73
DM
10use PVE::CLIHandler;
11
29505e2c
DM
12use PVE::APIClient::LWP;
13use PVE::APIClient::Helpers;
565bbc73
DM
14use PVE::APIClient::Commands::remote;
15
29505e2c
DM
16use JSON;
17
18sub print_usage {
19
c5111270
DM
20 my $text = "pveclient usage:\n\n";
21
22 $text .= "pveclient remote <help|add|remove> {options}\n\n";
23
24 $text .= "pveclient <get/set/create/delete> <path> {options}\n\n";
25
26 print STDERR $text;
27
29505e2c
DM
28}
29
30sub call_method {
31 my ($path, $method, $args) = @_;
32
33 die "missing API path\n" if !defined($path);
34
35 my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
a04fd959 36 my $param = PVE::JSONSchema::get_options($info->{parameters}, $args);
29505e2c
DM
37 print Dumper($param);
38
39 die "implement me";
40}
41
42# NOTE: This binary is just a placeholer - nothing implemented so far!
43
44#my $hostname = 'localhost';
45#my $username = 'root@pam';
46#
47#my $conn = PVE::APIClient::LWP->new(
48# username => $username,
49# #password => 'yourpassword',
50# #ticket => $ticket,
51# #csrftoken => $csrftoken,
52# host => $hostname,
53# # allow manual fingerprint verification
54# manual_verification => 1,
55# );
56
57#my $res = $conn->get("/", {});
58#print to_json($res, { pretty => 1, canonical => 1});
59
c5111270 60my $cmd = shift || (print_usage() && exit(-1));
29505e2c
DM
61
62if ($cmd eq 'get') {
63 my $method = 'GET';
64 my $path;
65 if (scalar(@ARGV) && $ARGV[0] !~ m/^\-/) {
66 $path = shift @ARGV;
67 }
68 my $res = call_method($path, $method, \@ARGV);
69 die "implement me";
70} elsif ($cmd eq 'set') {
71 die "implement me";
72} elsif ($cmd eq 'create') {
73 die "implement me";
74} elsif ($cmd eq 'delete') {
75 die "implement me";
565bbc73
DM
76} elsif ($cmd eq 'remote') {
77 PVE::APIClient::Commands::remote->run_cli_handler();
29505e2c
DM
78} else {
79 print_usage();
80}
81
565bbc73 82exit(0);