2024-04-12 12:10:17 +03:00
|
|
|
## Taskman
|
|
|
|
|
|
|
|
Taskman is a simple library which allows to conveniently execute 'tasks' written in PHP from the shell. Tasks can have dependencies on other tasks.
|
|
|
|
|
|
|
|
Taskman is inspired by Make, Capistrano, Ant, Maven and similar build tools.
|
|
|
|
|
|
|
|
The central unit of execution is 'task'. The main difference from the plain old function is the fact 'task' is executed **only once** no matter what.
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
#### Hello world
|
|
|
|
Here's a simple example of a task:
|
|
|
|
|
|
|
|
```
|
|
|
|
<?php
|
|
|
|
namespace taskman;
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
task('hello', function()
|
|
|
|
{
|
|
|
|
echo "Hello world!\n";
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Try executing it from the shell:
|
|
|
|
|
|
|
|
```./gamectl hello
|
|
|
|
***** task 'hello' start *****
|
|
|
|
Hello world!
|
|
|
|
***** task 'hello' done(0/0.27 sec.) *****
|
|
|
|
***** All done (0.27 sec.) *****
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Real world example
|
|
|
|
|
|
|
|
```
|
|
|
|
<?php
|
|
|
|
namespace taskman;
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
task('ultimate_build_run',
|
|
|
|
[
|
|
|
|
'default' => true,
|
|
|
|
'alias' => 'urun',
|
|
|
|
'deps' => ['autogen', 'pack_configs', 'ensure_unity_player_settings', 'unity_defines']
|
|
|
|
], function() {});
|
|
|
|
```
|
|
|
|
### Tasks documentation
|
|
|
|
|
|
|
|
### Task declaration
|
|
|
|
|
|
|
|
Task must be declared using library **task** function as follows:
|
|
|
|
|
|
|
|
```task('name', function() {});```
|
|
|
|
|
|
|
|
The task above now can be invoked from the shell as follows:
|
|
|
|
|
|
|
|
```./gamectl name```
|
|
|
|
|
|
|
|
### Task aliases
|
|
|
|
|
|
|
|
Task may have an alias for less typing in the shell:
|
|
|
|
|
|
|
|
```
|
|
|
|
task('name', ['alias' => 'n'],
|
|
|
|
function() {});
|
|
|
|
```
|
|
|
|
|
|
|
|
You can invoke the task by the alias as follows:
|
|
|
|
|
|
|
|
```./gamectl n```
|
|
|
|
|
|
|
|
### Task dependencies
|
|
|
|
|
|
|
|
Task may have an dependencies on other tasks:
|
|
|
|
|
|
|
|
```
|
|
|
|
task('c', ['deps' => ['a', 'b'],
|
|
|
|
function() {});
|
|
|
|
```
|
|
|
|
|
|
|
|
All dependencies are executed before running the specified task. Running the task above should output something as follows:
|
|
|
|
```
|
|
|
|
./gamectl c
|
|
|
|
***** task 'c' start *****
|
|
|
|
***** -task 'a' start *****
|
|
|
|
***** -task 'a' done(0/0.18 sec.) *****
|
|
|
|
***** -task 'b' start *****
|
|
|
|
***** -task 'b' done(0/0.18 sec.) *****
|
|
|
|
***** task 'c' done(0/0.18 sec.) *****
|
|
|
|
***** All done (0.18 sec.) *****
|
|
|
|
```
|
|
|
|
|