/
Thessia
executable file
·44 lines (35 loc) · 1.01 KB
/
Thessia
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
#!/usr/bin/env php7.0
<?php
// Error logging
ini_set("display_errors", 1);
error_reporting(E_ALL);
// Change to this directory
chdir(__DIR__);
// Load init
require_once(__DIR__ . "/init.php");
// Launch the CLI
$cli = new Symfony\Component\Console\Application("Embrace Eternity");
$tasks = array(__DIR__ . "/tasks/*.php", __DIR__ . "/tasks/CLI/*.php");
// Load all the commands
foreach ($tasks as $task) {
$files = glob($task);
foreach ($files as $file) {
require_once($file);
$file = str_replace(__DIR__ . "/", "", $file);
$name = str_replace(".php", "", basename($file));
$namespace = ucfirst(str_replace("/", "\\", str_replace(".php", "", $file)));
$import = "\\Thessia\\{$namespace}";
$cli->add(new $import());
}
}
$cli->run();
// Prompter
function prompt($prompt, $default = "")
{
echo "$prompt [$default] ";
$answer = trim(fgets(STDIN));
if (strlen($answer) == 0) {
return $default == "yes" ? true : $default;
}
return $answer;
}