[pve-devel] [PATCH common v2 9/9] cli: document $cmddef structure

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Dec 29 12:43:05 CET 2017


On Mon, Dec 18, 2017 at 10:21:43AM +0100, Thomas Lamprecht wrote:
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>

once the rest is finished:

Acked-by: Wolfgang Bumiller <w.bumiller at proxmox.com>

> ---
>  src/PVE/CLIHandler.pm | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
> index 76b14c9..fd57d0f 100644
> --- a/src/PVE/CLIHandler.pm
> +++ b/src/PVE/CLIHandler.pm
> @@ -10,6 +10,29 @@ use PVE::INotify;
>  
>  use base qw(PVE::RESTHandler);
>  
> +# $cmddef defines which (sub)commands are available in a specific CLI class.
> +# A real command is always an array consisting of its class, name, array of
> +# position fixed (required) parameters and hash of predefined parameters when
> +# mapping a CLI command t o an API call. Optionally an output method can be
> +# passed at the end, e.g., for formatting or transformation purpose.
> +#
> +# [class, name, fixed_params, API_pre-set params, output_sub ]
> +#
> +# In case of so called 'simple commands', the $cmddef can be also just an
> +# array.
> +#
> +# Examples:
> +# $cmddef = {
> +#     command => [ 'PVE::API2::Class', 'command', [ 'arg1', 'arg2' ], { node => $nodename } ],
> +#     do => {
> +#         this => [ 'PVE::API2::OtherClass', 'method', [ 'arg1' ], undef, sub {
> +#             my ($res) = @_;
> +#             print "$res\n";
> +#         }],
> +#         that => [ 'PVE::API2::OtherClass', 'subroutine' [] ],
> +#     },
> +#     dothat => { alias => 'do that' },
> +# }
>  my $cmddef;
>  my $exename;
>  my $cli_handler_class;
> -- 
> 2.11.0




More information about the pve-devel mailing list