Skip to content

Commit

Permalink
docs(Minion): strip redundant tabs or replace with 4 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kilofox committed Aug 4, 2023
1 parent 754eb02 commit 5ad33f6
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions modules/minion/guide/minion/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

Writing a task in minion is very easy. Simply create a new class called `Task_<Taskname>` and put it inside `classes/task/<taskname>.php`.

<?php defined('SYSPATH') or die('No direct script access.');

class Task_Demo extends Minion_Task
{
protected $_options = array(
'foo' => 'bar',
'bar' => null,
);

/**
* This is a demo task
*
* @return null
*/
protected function _execute(array $params)
{
var_dump($params);
echo 'foobar';
}
}
<?php defined('SYSPATH') or die('No direct script access.');

class Task_Demo extends Minion_Task
{
protected $_options = array(
'foo' => 'bar',
'bar' => null,
);

/**
* This is a demo task
*
* @return null
*/
protected function _execute(array $params)
{
var_dump($params);
echo 'foobar';
}
}

You'll notice a few things here:

Expand All @@ -38,34 +38,34 @@ You can "namespace" tasks by placing them all in a subdirectory: `classes/task/d

To add validations to your command line options, simply overload the `build_validation()` method in your task:

public function build_validation(Validation $validation)
{
return parent::build_validation($validation)
->rule('foo', 'not_empty') // Require this param
->rule('bar', 'numeric'); // This param should be numeric
}
public function build_validation(Validation $validation)
{
return parent::build_validation($validation)
->rule('foo', 'not_empty') // Require this param
->rule('bar', 'numeric'); // This param should be numeric
}

These validations will run for every task call unless `--help` is passed to the task.

# Task Help

Tasks can have built-in help. Minion will read class docblocks that you specify:

<?php defined('SYSPATH') or die('No direct script access.');

/**
* This is a demo task.
*
* It can accept the following options:
* - foo: this parameter does something. It is required.
* - bar: this parameter does something else. It should be numeric.
*
* @package Kohana
* @category Helpers
* @author Kohana Team
* @copyright (c) 2009-2011 Kohana Team
* @license http://kohanaframework.org/license
*/
class Minion_Task_Demo extends Minion_Task
<?php defined('SYSPATH') or die('No direct script access.');

/**
* This is a demo task.
*
* It can accept the following options:
* - foo: this parameter does something. It is required.
* - bar: this parameter does something else. It should be numeric.
*
* @package Kohana
* @category Helpers
* @author Kohana Team
* @copyright (c) 2009-2011 Kohana Team
* @license http://kohanaframework.org/license
*/
class Minion_Task_Demo extends Minion_Task

The `@` tags in the class comments will also be displayed in a human readable format. When writing your task comments, you should specify how to use it, and any parameters it accepts.

0 comments on commit 5ad33f6

Please sign in to comment.