https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43564
--- Comment #1 from Bastien Chauvet <[email protected]> --- Created attachment 206317 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206317&action=edit Bug 43564: Add ability to pass arguments to plugins in plugins_nightly.pl Added a new option '-a|--argument', accepting 'key=value' parameters, and gives its hashref to the cronjob_nightly() method used by plugins. Test plan: 1- Make sure you have any plugin you will be able to edit with cronjob_nightly() method installed. Run {PATH}/plugins_nightly.pl, to observe standard behaviour of your plugin. 2- Apply patch. 3- Run plugins_nightly.pl and check if plugin is running as intended. 4- Modify your plugin's cronjob_nightly() method to accept and use a hashref passed as argument : - modify the first line of the method: my ($self) = @_; --> my ($self, $args) = @_; - add a way to check on specific hash keys and values, e.g 'foo=Bob' and 'bar=Alice': say exists $args->{foo} ? $args->{foo} : "No foo"; if (exists $args->{bar}) { if ($args->{bar} eq "Alice") { say "bar is Alice"; } else { say "bar is not Alice"; } } - Feel free to adapt those lines to test deeper interactions. 5- Run plugins_nightly.pl again, mutiple times with different arguments : {PATH}/plugins_nightly.pl -a 'foo=Bob' 'bar=Alice' {PATH}/plugins_nightly.pl --argument 'foo=Bob' -a 'bar=Alice' {PATH}/plugins_nightly.pl -a 'foo=Bob' {PATH}/plugins_nightly.pl --argument 'bar=Alice' {PATH}/plugins_nightly.pl -a 'bar=John' {PATH}/plugins_nightly.pl -a 'unknownKey=unknownValue' Once again, you can try out more options (such as commands with --metadata, used to filter executed plugins), Also, make sure "{PATH}/plugins_nightly.pl" executed with no option still works as intended. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
