mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 11:44:45 +00:00
add helpers to verify API without starting the binary
In future, we want to have a separate PVE::CLI::$binname class for each binary. We can then simply load that class to verify the API: use PVE::CLI::pct; PVE::CLI::pct->verify_api(); or to generate the docs: PVE::CLI::pct->generate_pod_manpage();
This commit is contained in:
parent
1068aeb398
commit
1f130ba641
@ -261,6 +261,39 @@ my $print_bash_completion = sub {
|
|||||||
&$print_result(@option_list);
|
&$print_result(@option_list);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sub verify_api {
|
||||||
|
my ($class) = @_;
|
||||||
|
|
||||||
|
# simply verify all registered methods
|
||||||
|
PVE::RESTHandler::validate_method_schemas();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub generate_pod_manpage {
|
||||||
|
my ($class, $podfn) = @_;
|
||||||
|
|
||||||
|
no strict 'refs';
|
||||||
|
$cmddef = ${"${class}::cmddef"};
|
||||||
|
|
||||||
|
$exename = $class;
|
||||||
|
$exename =~ s/^.*:://;
|
||||||
|
|
||||||
|
if (!defined($podfn)) {
|
||||||
|
my $cpath = "$class.pm";
|
||||||
|
$cpath =~ s/::/\//g;
|
||||||
|
foreach my $p (@INC) {
|
||||||
|
my $testfn = "$p/$cpath";
|
||||||
|
if (-f $testfn) {
|
||||||
|
$podfn = $testfn;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
die "unable to find source for class '$class'" if !$podfn;
|
||||||
|
|
||||||
|
print_pod_manpage($podfn);
|
||||||
|
}
|
||||||
|
|
||||||
sub handle_cmd {
|
sub handle_cmd {
|
||||||
my ($def, $cmdname, $cmd, $args, $pwcallback, $podfn, $preparefunc) = @_;
|
my ($def, $cmdname, $cmd, $args, $pwcallback, $podfn, $preparefunc) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user