-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasker.php
52 lines (34 loc) · 984 Bytes
/
tasker.php
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
51
52
<?php
use jc21\CliTable;
require "bootstrap.php";
/**
* Say hello to someone
*/
task("hello", function(string $name){
writeln(sprintf("Hello %s!", $name));
});
task('db:clean', function(){
run("rm -rf flatbase/*");
});
task('db:seed', function($which){
run(sprintf("php seeder.php %s", $which), function($output) use($which){
if(empty($output))
$output = sprintf("[%s] was seeded.", $which);
echo sprintf("%s\n", $output);
});
});
task('db:ls', function(){
list($output, $error) = run("ls flatbase", function($output){
echo $output;
});
});
task("db:show", function($table) use($flatbase){
$rs = $flatbase->read()->in($table)->get()->getArrayCopy();
$table = new CliTable;
$table->setTableColor('blue');
$table->setHeaderColor('cyan');
foreach(array_keys($rs[0]) as $field)
$table->addField($field, $field);
$table->injectData($rs);
$table->display();
});