Skip to content

Commit

Permalink
updated package as Toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Biuhub Studio committed May 17, 2019
1 parent fe5a46d commit 4f48fb3
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Test/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Console\Test;
namespace Radion\Toolbox\ConsoleLite\Test;

use PHPUnit\Framework\TestCase;
use Radion\Component\Console\Application;
use Radion\Component\Console\Command;
use Radion\Toolbox\ConsoleLite\Application;
use Radion\Toolbox\ConsoleLite\Command;

class CommandTest extends TestCase
{
Expand Down
31 changes: 23 additions & 8 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* @author Muhammad Syifa <emsifa@gmail.com>
*/

namespace Radion\Component\Console;
namespace Radion\Toolbox\ConsoleLite;

use Closure;
use Exception;
use InvalidArgumentException;
use Radion\Autoloader\Console\Exception\JetError;
use Radion\Component\Console\Command\CommandList;
use Radion\Toolbox\ConsoleLite\Exception\JetError;
use Radion\Toolbox\ConsoleLite\Command\CommandList;

class Application
{
Expand All @@ -44,7 +44,6 @@ class Application
protected $resolvedOptions = [];
protected $formatter;
protected $errorhandle;
protected $autoloadone;

/** @var array PSR-3 compatible foreground color and their prefix, color, output channel */
protected $foregroundColors = [
Expand Down Expand Up @@ -99,7 +98,6 @@ private function loadCommands()
{
$this->command('hello {name?::Enter a name}', 'Enter your name to start', function ($name) {
$this->block("Hello {$name}, Nice Meeting you, I'm Biurad Slim Lite Console.", 'white', 'black');

});
}

Expand Down Expand Up @@ -310,7 +308,7 @@ public function execute($command)

call_user_func_array($handler, $arguments);
} catch (JetError $e) {
throw new JetError('The Application runned into an error', $e->getCode());
$this->handleError($e);
}
}

Expand Down Expand Up @@ -527,7 +525,7 @@ public function block($message, $fgColor = null, $bgColor = null, $width = null)
if ($width !== null) {
$this->formatter->setMaxWidth($width);
} else {
// do nothing.
$this->formatter->getMaxWidth();
}
$this->line();
$this->line(1, true);
Expand All @@ -539,6 +537,18 @@ public function block($message, $fgColor = null, $bgColor = null, $width = null)
$this->line();
}

/**
* Write a help block
*
* @param mixed $name is the subject
* @param string $description is the description
* @return void
*/
public function helpblock($name, $description)
{
return $this->writeln(' '.$this->style($name, 'purple').str_repeat(' ', 2 - strlen($name)) . ' -> ' . $description);
}

/**
* @param string $fgcolor
* @param string $message
Expand Down Expand Up @@ -1069,7 +1079,12 @@ public function handleError(\Throwable $exception)
{
//$exception = new Exception;
$indent = str_repeat(' ', 2);
$class = get_class($exception);
//$class = get_class($exception);
if (get_class($exception) === 'Radion\Toolbox\ConsoleLite\Exception\JetError') {
$class = 'Application Error';
} else {
$class = get_class($exception);
}
$file = $exception->getFile();
$line = $exception->getLine();
$filepath = function ($file) {
Expand Down
2 changes: 1 addition & 1 deletion src/Colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Component\Console;
namespace Radion\Toolbox\ConsoleLite;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @author Muhammad Syifa <emsifa@gmail.com>
*/

namespace Radion\Component\Console;
namespace Radion\Toolbox\ConsoleLite;

abstract class Command
{
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CommandList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Component\Console\Command;
namespace Radion\Toolbox\ConsoleLite\Command;

use Radion\Component\Console\Command;
use Radion\Toolbox\ConsoleLite\Command;

class CommandList extends Command
{
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/FileUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Component\Console\Concerns;
namespace Radion\Toolbox\ConsoleLite\Concerns;

class FileUtils
{
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/InputUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @author Muhammad Syifa <emsifa@gmail.com>
*/

namespace Radion\Component\Console\Concerns;
namespace Radion\Toolbox\ConsoleLite\Concerns;

use RuntimeException;

Expand Down
4 changes: 2 additions & 2 deletions src/Exception/JetError.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Autoloader\Console\Exception;
namespace Radion\Toolbox\ConsoleLite\Exception;

/**
* JetError.
Expand All @@ -28,6 +28,6 @@ class JetError extends \Exception implements \Throwable
{
public function run()
{
set_exception_handler('Radion\Autoloader\Console\Application::exception');
set_exception_handler('Radion\Toolbox\ConsoleLite\Application::exception');
}
}
2 changes: 1 addition & 1 deletion src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Component\Console;
namespace Radion\Toolbox\ConsoleLite;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/PSR3.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Divine Niiquaye <hello@biuhub.net>
*/

namespace Radion\Component\Console;
namespace Radion\Toolbox\ConsoleLite;

use Psr\Log\LoggerInterface;

Expand Down

0 comments on commit 4f48fb3

Please sign in to comment.