Skip to content

Commit

Permalink
update lite sytle and format codes
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 20, 2017
1 parent 2370497 commit 5636344
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 154 deletions.
8 changes: 4 additions & 4 deletions src/Base/AbstractApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ protected function runtimeCheck()
if (!in_array(PHP_SAPI, ['cli', 'cli-server'], true)) {
header('HTTP/1.1 403 Forbidden');
exit(" 403 Forbidden \n\n"
. " current environment is CLI. \n"
. " :( Sorry! Run this script is only allowed in the terminal environment!\n,You are not allowed to access this file.\n");
. " current environment is CLI. \n"
. " :( Sorry! Run this script is only allowed in the terminal environment!\n,You are not allowed to access this file.\n");
}
}

Expand Down Expand Up @@ -161,7 +161,7 @@ public function run($exit = true)
self::fire(self::ON_AFTER_RUN, [$this]);

if ($exit) {
$this->stop((int) $returnCode);
$this->stop((int)$returnCode);
}
}

Expand All @@ -179,7 +179,7 @@ public function stop($code = 0)
// call 'onAppStop' service, if it is registered.
self::fire(self::ON_STOP_RUN, [$this]);

exit((int) $code);
exit((int)$code);
}


Expand Down
17 changes: 9 additions & 8 deletions src/Base/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public function __construct(Input $input, Output $output, InputDefinition $defin
}

protected function init()
{}
{
}

/**
* configure input definition
Expand Down Expand Up @@ -122,7 +123,7 @@ public function run()
// load input definition configure
$this->configure();

if ($this->input->sameOpt(['h','help'])) {
if ($this->input->sameOpt(['h', 'help'])) {
return $this->showHelp();
}

Expand Down Expand Up @@ -309,7 +310,7 @@ protected function replaceAnnotationVars($str)

/**
* show help by parse method annotation
* @param string $method
* @param string $method
* @param null|string $action
* @return int
*/
Expand Down Expand Up @@ -343,12 +344,12 @@ protected function showHelpByMethodAnnotation($method, $action = null)

// need multi align
// if (self::$annotationTags[$tag]) {
// $lines = array_map(function ($line) {
// // return trim($line);
// return $line;
// }, explode("\n", $msg));
// $lines = array_map(function ($line) {
// // return trim($line);
// return $line;
// }, explode("\n", $msg));

// $msg = implode("\n", array_filter($lines, 'trim'));
// $msg = implode("\n", array_filter($lines, 'trim'));
// }

$tag = ucfirst($tag);
Expand Down
1 change: 1 addition & 0 deletions src/Base/ApplicationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface ApplicationInterface
const ON_NOT_FOUND = 'notFound';

public function run($exit = true);

public function stop($code = 0);

public function controller(string $name, string $controller = null);
Expand Down
8 changes: 4 additions & 4 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ abstract class Command extends AbstractCommand
*/
// protected function configure()
// {
// $this
// ->createDefinition()
// ->addArgument('test')
// ->addOption('test');
// $this
// ->createDefinition()
// ->addArgument('test')
// ->addOption('test');
// }

/**
Expand Down
5 changes: 5 additions & 0 deletions src/IO/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public function getSameArg(array $names, $default = null)
{
return $this->sameArg($names, $default);
}

public function sameArg(array $names, $default = null)
{
foreach ($names as $name) {
Expand Down Expand Up @@ -325,6 +326,7 @@ public function getBoolOpt(string $name, $default = false): bool
{
return (bool)$this->getOpt($name, $default);
}

public function boolOpt(string $name, $default = false): bool
{
return (bool)$this->getOpt($name, $default);
Expand Down Expand Up @@ -356,6 +358,7 @@ public function getSameOpt(array $names, $default = null)
{
return $this->sameOpt($names, $default);
}

public function sameOpt(array $names, $default = null)
{
foreach ($names as $name) {
Expand All @@ -379,6 +382,7 @@ public function sOpt($name, $default = null)
{
return $this->sOpts[$name] ?? $default;
}

public function getShortOpt($name, $default = null)
{
return $this->sOpts[$name] ?? $default;
Expand Down Expand Up @@ -444,6 +448,7 @@ public function lOpt($name, $default = null)
{
return $this->lOpts[$name] ?? $default;
}

public function getLongOpt($name, $default = null)
{
return $this->lOpts[$name] ?? $default;
Expand Down
2 changes: 1 addition & 1 deletion src/IO/InputDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function getSynopsis($short = false)
$elements[] = sprintf('[%s--%s%s]', $shortcut, $name, $value);

$key = "{$shortcut}--{$name}";
$opts[$key] = ($option['required'] ? '<red>*</red>' : '') .$option['description'];
$opts[$key] = ($option['required'] ? '<red>*</red>' : '') . $option['description'];
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/IO/InputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface InputInterface
const ARG_OPTIONAL = 2;
const ARG_IS_ARRAY = 4;

const OPT_BOOLEAN = 1;
const OPT_BOOLEAN = 1;
const OPT_REQUIRED = 2;
const OPT_OPTIONAL = 4;
const OPT_IS_ARRAY = 8;
Expand Down
4 changes: 2 additions & 2 deletions src/LiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class LiteApplication
*/
private $opts = [];

/** @var string */
/** @var string */
private $script = '';

/** @var string */
/** @var string */
private $command = '';

/**
Expand Down
34 changes: 17 additions & 17 deletions src/Style/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ final class Color
const BG_BASE = 40;

// color
const BLACK = 'black';
const RED = 'red';
const GREEN = 'green';
const YELLOW = 'yellow'; // BROWN
const BLUE = 'blue';
const MAGENTA = 'magenta';
const CYAN = 'cyan';
const WHITE = 'white';
const NORMAL = 'normal';
const BLACK = 'black';
const RED = 'red';
const GREEN = 'green';
const YELLOW = 'yellow'; // BROWN
const BLUE = 'blue';
const MAGENTA = 'magenta';
const CYAN = 'cyan';
const WHITE = 'white';
const NORMAL = 'normal';

// color option
const BOLD = 'bold'; // 加粗
const FUZZY = 'fuzzy'; // 模糊(不是所有的终端仿真器都支持)
const ITALIC = 'italic'; // 斜体(不是所有的终端仿真器都支持)
const UNDERSCORE = 'underscore'; // 下划线
const BLINK = 'blink'; // 闪烁
const REVERSE = 'reverse'; // 颠倒的 交换背景色与前景色
const CONCEALED = 'concealed'; // 隐匿的
const BOLD = 'bold'; // 加粗
const FUZZY = 'fuzzy'; // 模糊(不是所有的终端仿真器都支持)
const ITALIC = 'italic'; // 斜体(不是所有的终端仿真器都支持)
const UNDERSCORE = 'underscore'; // 下划线
const BLINK = 'blink'; // 闪烁
const REVERSE = 'reverse'; // 颠倒的 交换背景色与前景色
const CONCEALED = 'concealed'; // 隐匿的

/**
* Known color list
Expand Down Expand Up @@ -90,7 +90,7 @@ final class Color
/**
* @param string $fg
* @param string $bg
* @param array $options
* @param array $options
* @return Color
*/
public static function make($fg = '', $bg = '', array $options = [])
Expand Down
Loading

0 comments on commit 5636344

Please sign in to comment.