diff --git a/console b/console index aab334c..f9af763 100755 --- a/console +++ b/console @@ -6,4 +6,8 @@ require_once __DIR__ . '/vendor/autoload.php'; use Console\Application; $app = new Application(); -$app->run(); + +$app + ->chdir(__DIR__) + ->loadCommands() + ->run(); diff --git a/src/Console/Application.php b/src/Console/Application.php index a5e434e..bd52d6e 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -11,21 +11,21 @@ class Application extends BaseApplication 'src/Console/Command' => 'Console\\Command', ); - public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') - { - parent::__construct($name, $version); - - $this->loadCommands(); - } - public function addCommandsPath($path, $namespace) { - $this->commandsPaths[$path] = trim($namespace, '/'); + $this->commandsPaths[$path] = trim($namespace, '\\'); return $this; } - protected function loadCommands() + public function chdir($directory) + { + chdir($directory); + + return $this; + } + + public function loadCommands() { $finder = new Finder(); @@ -39,5 +39,7 @@ class Application extends BaseApplication )); } } + + return $this; } }