X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=pveclient;h=46d902daca0952866eba0360d6d96e7ad9b14758;hp=091af96bb160a2ee7ab79a3e029794984770a9d0;hb=032dc44cfeb5be68d715c12c1baf47d8e124d61d;hpb=a8aa5b63711a9b0ee8536aac91901b1b38609c09 diff --git a/pveclient b/pveclient index 091af96..46d902d 100755 --- a/pveclient +++ b/pveclient @@ -2,6 +2,7 @@ use strict; use warnings; +use Cwd 'abs_path'; use lib '/usr/share/pve-client'; use lib '.'; use Data::Dumper; @@ -13,23 +14,10 @@ use PVE::APIClient::LWP; use PVE::APIClient::Helpers; use PVE::APIClient::Commands::remote; use PVE::APIClient::Commands::lxc; +use PVE::APIClient::Commands::help; use JSON; -sub print_usage { - - my $text = "pveclient usage:\n\n"; - - $text .= "pveclient remote {options}\n\n"; - - $text .= "pveclient lxc {options}\n\n"; - - $text .= "pveclient {options}\n\n"; - - print STDERR $text; - -} - sub call_method { my ($path, $method, $args) = @_; @@ -42,30 +30,17 @@ sub call_method { die "implement me"; } -# NOTE: This binary is just a placeholer - nothing implemented so far! - -#my $hostname = 'localhost'; -#my $username = 'root@pam'; -# -#my $conn = PVE::APIClient::LWP->new( -# username => $username, -# #password => 'yourpassword', -# #ticket => $ticket, -# #csrftoken => $csrftoken, -# host => $hostname, -# # allow manual fingerprint verification -# manual_verification => 1, -# ); - -#my $res = $conn->get("/", {}); -#print to_json($res, { pretty => 1, canonical => 1}); - my $cli_class_handlers = { lxc => 'PVE::APIClient::Commands::lxc', remote => 'PVE::APIClient::Commands::remote', + help => 'PVE::APIClient::Commands::help', }; -my $cmd = shift || (print_usage() && exit(-1)); +my $cmd = shift; +if (!defined($cmd)) { + PVE::APIClient::Commands::help->help({}); + exit(-1); +} if ($cmd eq 'get') { my $method = 'GET'; @@ -113,8 +88,26 @@ if ($cmd eq 'get') { } } +} elsif ($cmd eq 'packagedepends') { + # experimental code to print required perl packages + my $packages = {}; + my $dir = Cwd::getcwd; + + foreach my $k (keys %INC) { + my $file = abs_path($INC{$k}); + next if $file =~ m/^\Q$dir\E/; + my $res = `dpkg -S '$file'`; + if ($res && $res =~ m/^(\S+): $file$/) { + my $debian_package = $1; + $debian_package =~ s/:amd64$//; + $packages->{$debian_package} = 1; + } else { + die "unable to find package for '$file'\n"; + } + } + print join("\n", sort(keys %$packages)) . "\n"; } else { - print_usage(); + PVE::APIClient::Commands::help->help({}); } exit(0);