-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.php
67 lines (61 loc) · 2.14 KB
/
loader.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace myo;
abstract class loader
{
const ASCILOGO = '
_ __ ___ _ _ ___
| \'_ ` _ \| | | |/ _ \
| | | | | | |_| | (_) |
|_| |_| |_|\__, |\___/
__/ |
|___/
';
const USAGE = ' Phiber\'s Command Line Tool ';
const AUTHOR =' Author: Housseyn Guettaf <ghoucine@gmail.com>';
const VERSION = 'v0.6.5';
protected $root = __dir__;
protected $requireConfig = false;
protected $appConfig;
protected $args = array(
'commands' => array(),
'options' => array(),
'flags' => array(),
'arguments' => array(),
);
protected $interactive = false;
protected $helpFile = 'HELP';
public function usage()
{
$usage = PHP_EOL.self::ASCILOGO.self::USAGE.self::VERSION.PHP_EOL.self::AUTHOR.PHP_EOL;
$usage .= PHP_EOL.' Usage:'.PHP_EOL.PHP_EOL;
$usage .= ' myo <comand> <flag> [[--option1 value][--option2 = value]...] -- arg1 arg2 ...'.PHP_EOL.PHP_EOL.PHP_EOL;
$usage .= ' Flags:'.PHP_EOL.PHP_EOL;
$usage .= " -i\tPreserve case otherwise files will always be created in lowercase".PHP_EOL.PHP_EOL;
$usage .= " -g\tGenerate entity files when used with myo entity".PHP_EOL.PHP_EOL;
$usage .= PHP_EOL.PHP_EOL.' Options:'.PHP_EOL.PHP_EOL;
$path = __dir__.DIRECTORY_SEPARATOR.'cmd';
$list = scandir($path);
foreach($list as $ext){
if($ext != '.' && $ext != '..' ){
$extFQN = 'myo\\cmd\\'.$ext.'\\'.$ext;
$usage .= ' '.$ext."\t\t".$extFQN::USAGE.PHP_EOL;
}
}
print $usage;
}
public function autoload($className)
{
$className = str_replace('myo\\', '', $className);
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
}
?>