]> git.proxmox.com Git - pve-common.git/commitdiff
cli: document $cmddef structure
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Jan 2018 12:25:33 +0000 (13:25 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 18 Jan 2018 07:59:34 +0000 (08:59 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/CLIHandler.pm

index 1af9987c56c65d6b12a239df14177ae29627d632..caa7ca640ad37513627584c59d55368500fa6c86 100644 (file)
@@ -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;