Skip to content

Commit

Permalink
Merge pull request #101 from 10quality/feature/#100-coloring
Browse files Browse the repository at this point in the history
#100 Added coloring
  • Loading branch information
amostajo authored Feb 8, 2023
2 parents c991435 + bfd9e3b commit 58ba12f
Show file tree
Hide file tree
Showing 18 changed files with 104 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.10
* @version 1.1.17
*/
class AddCommand extends Command
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public function call($args = [])
$this->updateComment('version', $this->config['version'], $this->getMainClassPath());
} else {
// Print exists
$this->_print('Hook call exists!');
$this->_print_info('Hook call exists!');
$this->_lineBreak();
}
}
Expand Down
31 changes: 31 additions & 0 deletions src/Base/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace WPMVC\Commands\Base;

use Ayuco\Coloring;
use Ayuco\Command;
use Ayuco\Exceptions\NoticeException;
use WPMVC\Commands\Traits\FilesystemTrait;
Expand Down Expand Up @@ -297,4 +298,34 @@ public function confirm()
$yes = strtolower( $this->listener->getInput() );
return empty($yes) || substr($yes, 0, 1) === 'y' || $yes === 1;
}
/**
* Prints in success coloring.
* @since 1.1.17
*
* @param string $message
*/
public function _print_success($message)
{
$this->_print(Coloring::apply('color_10', $message));
}
/**
* Prints in info coloring.
* @since 1.1.17
*
* @param string $message
*/
public function _print_info($message)
{
$this->_print(Coloring::apply('color_27', $message));
}
/**
* Returns Yes|No.
* @since 1.1.17
*
* @return string
*/
public function yesno()
{
return '['.Coloring::apply('color_10', 'Yes').'|'.Coloring::apply('color_09', 'No').']';
}
}
14 changes: 7 additions & 7 deletions src/RegisterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.10
* @version 1.1.17
*/
class RegisterCommand extends Command
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public function call($args = [])
$this->updateComment('version', $this->config['version'], $this->getMainClassPath());
} else {
// Print exists
$this->_print('Hook call exists!');
$this->_print_info('Hook call exists!');
$this->_lineBreak();
}
break;
Expand All @@ -118,11 +118,11 @@ public function call($args = [])
// Update class version
$this->updateComment('version', $this->config['version'], $this->getMainClassPath());
// Print end
$this->_print('Model registered!');
$this->_print_success('Model registered!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Model registration exists!');
$this->_print_info('Model registration exists!');
$this->_lineBreak();
}
break;
Expand All @@ -140,16 +140,16 @@ public function call($args = [])
// Update class version
$this->updateComment('version', $this->config['version'], $this->getMainClassPath());
// Print end
$this->_print('Asset registered!');
$this->_print_success('Asset registered!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Asset registration exists!');
$this->_print_info('Asset registration exists!');
$this->_lineBreak();
}
} else {
// Print exists
$this->_print('Asset doesn\'t exist!');
$this->_print_info('Asset doesn\'t exist!');
$this->_lineBreak();
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.12
* @version 1.1.17
*/
class SetupCommand extends Command
{
Expand Down Expand Up @@ -157,7 +157,7 @@ public function call($args = [])
$this->_lineBreak();
$this->_print('Your project\'s license is "%s"', $this->config['license']);
$this->_lineBreak();
$this->_print('Setup completed!');
$this->_print_success('Setup completed!');
$this->_lineBreak();
$this->_print('------------------------------');
$this->_lineBreak();
Expand Down
10 changes: 5 additions & 5 deletions src/Traits/CreateAssetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.10
* @version 1.1.17
*/
trait CreateAssetTrait
{
Expand Down Expand Up @@ -52,11 +52,11 @@ protected function createAsset($type, $filename, $args = [])
$this->getTemplate((array_key_exists('template', $args) ? $args['template'] : 'asset').'.'.$type)
));
// Print created
$this->_print($type.' asset created!');
$this->_print_success($type.' asset created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Asset exists!');
$this->_print_info('Asset exists!');
$this->_lineBreak();
}
break;
Expand Down Expand Up @@ -98,11 +98,11 @@ protected function createAsset($type, $filename, $args = [])
$this->getTemplate(($ispart ? 'asset' : 'master').'.'.$type)
));
// Print created
$this->_print($type.' asset created!');
$this->_print_success($type.' asset created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print($ispart ? 'Asset exists!' : 'Master asset exists!');
$this->_print_info($ispart ? 'Asset exists!' : 'Master asset exists!');
$this->_lineBreak();
}
// Add compiled file to .gitignore
Expand Down
12 changes: 6 additions & 6 deletions src/Traits/CreateControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.10
* @version 1.1.17
*/
trait CreateControllerTrait
{
Expand Down Expand Up @@ -53,11 +53,11 @@ protected function createController($name, $args = [])
)
);
// Print created
$this->_print('Controller created!');
$this->_print_success('Controller created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Controller exists!');
$this->_print_info('Controller exists!');
$this->_lineBreak();
}
} catch (Exception $e) {
Expand Down Expand Up @@ -136,11 +136,11 @@ protected function createModelController($name)
)
);
// Print created
$this->_print('Controller created!');
$this->_print_success('Controller created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Controller exists!');
$this->_print_info('Controller exists!');
$this->_lineBreak();
}
} catch (Exception $e) {
Expand Down Expand Up @@ -183,7 +183,7 @@ protected function createControllerProperty($controller, $property, $value = nul
}
} else {
// Print exists
$this->_print('Property exists!');
$this->_print_info('Property exists!');
$this->_lineBreak();
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Traits/CreateModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.10
* @version 1.1.17
*/
trait CreateModelTrait
{
Expand Down Expand Up @@ -56,11 +56,11 @@ protected function createModel($name, $type = 'PostModel', $trait = 'FindTrait')
)
);
// Print created
$this->_print('Model created!');
$this->_print_success('Model created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Model exists!');
$this->_print_info('Model exists!');
$this->_lineBreak();
}
} catch (Exception $e) {
Expand Down Expand Up @@ -102,7 +102,7 @@ protected function createModelMethod($model, $method, $params = [], $comment = '
}
} else {
// Print exists
$this->_print('Method exists!');
$this->_print_info('Method exists!');
$this->_lineBreak();
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ protected function createModelProperty($model, $property, $value = null, $type =
}
} else {
// Print exists
$this->_print('Property exists!');
$this->_print_info('Property exists!');
$this->_lineBreak();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Traits/CreateTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.12
* @version 1.1.17
*/
trait CreateTestTrait
{
Expand Down Expand Up @@ -50,11 +50,11 @@ protected function createTest($name, $args = [])
)
);
// Print created
$this->_print('Test case created!');
$this->_print_success('Test case created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('Test case exists!');
$this->_print_info('Test case exists!');
$this->_lineBreak();
}
} catch (Exception $e) {
Expand Down Expand Up @@ -96,7 +96,7 @@ protected function createTestMethod($test, $method, $params = [], $comment = '')
}
} else {
// Print exists
$this->_print('Test method exists!');
$this->_print_info('Test method exists!');
$this->_lineBreak();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Traits/CreateViewTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @copyright 10Quality <http://www.10quality.com>
* @license MIT
* @package WPMVC\Commands
* @version 1.1.12
* @version 1.1.17
*/
trait CreateViewTrait
{
Expand Down Expand Up @@ -50,11 +50,11 @@ protected function createView($key, $template = 'view.php')
$this->getTemplate($template))
);
// Print created
$this->_print('View created!');
$this->_print_success('View created!');
$this->_lineBreak();
} else {
// Print exists
$this->_print('View exists!');
$this->_print_info('View exists!');
$this->_lineBreak();
}
} else {
Expand Down
Loading

0 comments on commit 58ba12f

Please sign in to comment.