-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.pm
50 lines (40 loc) · 955 Bytes
/
Plugin.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
# Paulo Graça <[email protected]>
#
package Rex::Module::CMS::WP_CLI::Plugin;
use strict;
use warnings;
use Data::Dumper;
use Rex::Commands;
use Rex::Module::CMS::WP_CLI;
our $WP_CLI_COMMAND = 'plugin';
sub _execute {
my @params = @_;
my $param;
if ( ref $params[0] eq "HASH" ) {
$param = $params[0];
} else {
$param = {@params};
}
my @action = split(/\:/, $param->{task});
Rex::Module::CMS::WP_CLI::execute (
Rex::Module::CMS::WP_CLI::buildCommand(
command => $WP_CLI_COMMAND,
subcommand => $action[$#action],
parameters => $param,
), $param );
};
my @subcommands = qw( install uninstall delete activate deactivate update );
foreach my $subcommand (@subcommands) {
desc "$subcommand $WP_CLI_COMMAND";
task "$subcommand",
sub {
_execute(
task => task->name,
subparams => @_);
};
}
desc "alias for install";
task "setup" => sub {
_execute('install', @_);
};