Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions src/Console/Code.php

This file was deleted.

75 changes: 75 additions & 0 deletions src/Console/Colorize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* This file is part of the Zest Framework.
*
* @author Muhammad Umer Farooq (Malik) <mumerfarooqlablnet01@gmail.com>
*
* @link https://github.com/zestframework/Zest_Framework
*
* @author Muhammad Umer Farooq <lablnet01@gmail.com>
* @author-profile https://www.facebook.com/Muhammadumerfarooq01/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
*/

namespace Zest\Console;

use Zest\Data\Arrays;

class Colorize
{
/**
* Foregroud colors.
*
* @since 3.0.0
*
* @var array
*/
public $styles = [
'bold' => '1m',
'faded' => '2m',
'underlined' => '4m',
'blinking' => '5m',
'reversed' => '7m',
'hidden' => '8m',
'red' => '31m',
'green' => '32m',
'yellow' => '33m',
'blue' => '34m',
'magenta' => '35m',
'cyan' => '36m',
'light_gray' => '37m',
'dark_gray' => '90m',
'white' => '0m',
'bg:red' => '41m',
'bg:green' => '42m',
'bg:yellow' => '53m',
'bg:blue' => '44m',
'bg:magenta' => '45m',
'bg:cyan' => '46m',
'bg:light_gray' => '47m',
'bg:dark_gray' => '100m',
'bg:white' => '0m',
];

/**
* Get the color by key.
*
* @param string $color Color key
* @param bool $background
*
* @since 3.0.0
*
* @var string
*/
public function get(string $style)
{
if (Arrays::has($this->styles, $style, '.')) {
return Arrays::get($this->styles, $style, '.');
}
}
}
156 changes: 156 additions & 0 deletions src/Console/Command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php

/**
* This file is part of the Zest Framework.
*
* @author Muhammad Umer Farooq (Malik) <mumerfarooqlablnet01@gmail.com>
*
* @link https://github.com/zestframework/Zest_Framework
*
* @author Muhammad Umer Farooq <lablnet01@gmail.com>
* @author-profile https://www.facebook.com/Muhammadumerfarooq01/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
*/

namespace Zest\Console;

abstract class Command
{
/**
* Sign of the command.
*
* @since 3.0.0
*
* @var string
*/
protected $sign;

/**
* Description of the command.
*
* @since 3.0.0
*
* @var string
*/
protected $description;

/**
* Should the command hidden form list.
*
* @since 3.0.0
*
* @var bool
*/
protected $hidden = false;

/**
* Accpet flag parameter in command.
*
* @since 3.0.0
*
* @var array
*/
protected $flags = [];

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
//todo
}

/**
* Get hidden.
*
* @return string
*/
public function getHidden(): bool
{
return $this->hidden;
}

/**
* Get sign.
*
* @return string
*/
public function getSign(): string
{
return $this->sign ?? '';
}

/**
* Get description.
*
* @return string
*/
public function getDescription(): string
{
return $this->description ?? '';
}

/**
* Get flags.
*
* @return array
*/
public function getFlags(): array
{
return $this->flags ?? [];
}

/**
* Function to handle the class.
*
* @param string $str
* @param bool $newLine
*
* @return void
*/
public function write(string $str, bool $newLine = true)
{
(new Output())->write($str, $newLine);
}

/**
* Prompt user for input.
*
* @param string $str
*
* @return void
*/
public function ask(string $str)
{
$this->write("<white>$str</white>", false);

return (new Input())->ask();
}

/**
* Terminate the console.
*
* @return void
*/
public function terminate(): void
{
exit();
}

/**
* Function to handle the class.
*
* @param \Zest\Console\Output $output
* @param \Zest\Console\Input $input
* @param array $param
*
* @return void
*/
abstract public function handle(Output $output, Input $input, $prams = []): void;
}
50 changes: 50 additions & 0 deletions src/Console/Commands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* This file is part of the Zest Framework.
*
* @author Muhammad Umer Farooq (Malik) <mumerfarooqlablnet01@gmail.com>
*
* @link https://github.com/zestframework/Zest_Framework
*
* @author Muhammad Umer Farooq <lablnet01@gmail.com>
* @author-profile https://www.facebook.com/Muhammadumerfarooq01/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT
*/

namespace Zest\Console;

class Commands
{
/**
* Internal commands.
*
* @since 3.0.0
*
* @var array
*/
protected $commands = [
['version', \Zest\Console\Commands\Version::class],
['list', \Zest\Console\Commands\ListCmd::class],
['make:controller', \Zest\Console\Commands\Controller::class],
['clear:cache', \Zest\Console\Commands\Cache::class],
['serve', \Zest\Console\Commands\ServeCommand::class],

];

/**
* Get commands.
*
* @since 3.0.0
*
* @var array
*/
public function getCommands(): array
{
return $this->commands;
}
}
Loading