View | Details | Raw Unified | Return to bug 34335
Collapse All | Expand All

(-)a/misc/run_koha_plugin.pl (-1 / +69 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2023 Koha Development Team
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
=head1 NAME
22
23
run_koha_plugin.pl - Script to execute a Koha plugin from the CLI
24
25
=head1 SYNOPSIS
26
27
./run_koha_plugin --class Koha::Plugin::Awesome --method awesome_method
28
29
=head1 DESCRIPTION
30
31
This script will load the specified Koha plugin class and run the specified method
32
33
=head1 OPTIONS
34
35
=over
36
37
=item B<--class>
38
39
This is the class/package name of the Koha plugin in Perl module syntax
40
41
=item B<--method>
42
43
This is the name of the method to run. It must already be registered in Koha's
44
database.
45
46
=back
47
48
=cut
49
50
use Modern::Perl;
51
use Getopt::Long;
52
use Pod::Usage;
53
54
use Koha::Script;
55
use Koha::Plugins::Handler;
56
57
my $class;
58
my $method;
59
60
GetOptions(
61
    "class=s"  => \$class,
62
    "method=s" => \$method,
63
) || pod2usage(1);
64
65
if ( $class && $method ) {
66
    my $result = Koha::Plugins::Handler->run( { class => $class, method => $method } );
67
} else {
68
    pod2usage(1);
69
}

Return to bug 34335