Skip to content

Commit b86104a

Browse files
committed
update some logic, add more unit test
1 parent e23e807 commit b86104a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+324
-201
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,14 @@ $output->write('hello <info>world<info>');
408408

409409
![alt text](docs/screenshots/output-color-text.png "Title")
410410

411-
来自于类 `Inhere\Console\Utils\Show`
411+
来自于类 `Inhere\Console\Util\Show`
412412

413-
> output 实例拥有 `Inhere\Console\Utils\Show` 的所有格式化输出方法。不过都是通过对象式访问的。
413+
> output 实例拥有 `Inhere\Console\Util\Show` 的所有格式化输出方法。不过都是通过对象式访问的。
414414
415415
- **单独使用颜色风格**
416416

417417
```php
418-
$style = Inhere\Console\Components\Style\Style::create();
418+
$style = Inhere\Console\Component\Style\Style::create();
419419

420420
echo $style->render('no color <info>color text</info>');
421421

@@ -639,7 +639,7 @@ Show::helpPanel([
639639

640640
## 用户交互方法
641641

642-
> 要独立使用的话需引入类 `Inhere\Console\Utils\Interact``Controller``Command` 里可以直接调用相关方法
642+
> 要独立使用的话需引入类 `Inhere\Console\Util\Interact``Controller``Command` 里可以直接调用相关方法
643643
644644
### 读取用户输入
645645

README_en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ $output->write('hello');
188188

189189
## more interactive
190190

191-
in the class `Inhere\Console\Utils\Interact`
191+
in the class `Inhere\Console\Util\Interact`
192192

193193
interactive method:
194194

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
}
2222
],
2323
"require": {
24-
"php": ">7.0.0",
24+
"php": ">7.1.0",
2525
"toolkit/cli-utils": "~1.0",
26+
"toolkit/str-utils": "~1.0",
2627
"toolkit/sys-utils": "~1.0"
2728
},
2829
"autoload": {

examples/Commands/CorCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Inhere\Console\Command;
1212
use Inhere\Console\IO\Input;
1313
use Inhere\Console\IO\Output;
14-
use Inhere\Console\Utils\Helper;
14+
use Inhere\Console\Util\Helper;
1515

1616
/**
1717
* Class CorCommand

examples/Controllers/HomeController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace Inhere\Console\Examples\Controllers;
44

55
use Toolkit\Cli\Cli;
6-
use Inhere\Console\Components\Symbol\ArtFont;
6+
use Inhere\Console\Component\Symbol\ArtFont;
77
use Toolkit\Cli\Download;
88
use Inhere\Console\Controller;
99
use Inhere\Console\IO\Input;
10-
use Inhere\Console\Utils\Helper;
11-
use Inhere\Console\Utils\Interact;
12-
use Inhere\Console\Utils\ProgressBar;
13-
use Inhere\Console\Utils\Show;
10+
use Inhere\Console\Util\Helper;
11+
use Inhere\Console\Util\Interact;
12+
use Inhere\Console\Util\ProgressBar;
13+
use Inhere\Console\Util\Show;
1414

1515
/**
1616
* default command controller. there are some command usage examples(1)

examples/Controllers/InteractController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
namespace Inhere\Console\Examples\Controllers;
1010

1111
use Inhere\Console\Controller;
12-
use Inhere\Console\Utils\Interact;
13-
use Inhere\Console\Utils\Show;
12+
use Inhere\Console\Util\Interact;
13+
use Inhere\Console\Util\Show;
1414
use Toolkit\Cli\Terminal;
1515

1616
/**

examples/Controllers/ShowController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
namespace Inhere\Console\Examples\Controllers;
1010

11-
use Inhere\Console\Components\Symbol\Char;
12-
use Inhere\Console\Components\Symbol\Emoji;
11+
use Inhere\Console\Component\Symbol\Char;
12+
use Inhere\Console\Component\Symbol\Emoji;
1313
use Toolkit\Cli\Color;
1414
use Inhere\Console\Controller;
1515
use Inhere\Console\IO\Input;
16-
use Inhere\Console\Utils\Show;
16+
use Inhere\Console\Util\Show;
1717
use Toolkit\Cli\Highlighter;
1818

1919
/**

examples/demo/progress_bar1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
require dirname(__DIR__) . '/../../autoload.php';
33

4-
use Inhere\Console\Utils\ProgressBar;
4+
use Inhere\Console\Util\ProgressBar;
55

66
$i = 1;
77
$total = 100;

phar.build.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* User: Inhere
66
* Date: 2018/1/26 0026
77
* Time: 22:11
8-
* @var \Inhere\Console\Components\PharCompiler $compiler
8+
* @var \Inhere\Console\Component\PharCompiler $compiler
99
*/
1010

1111
// config

src/AbstractApplication.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Inhere\Console;
1010

11-
use Inhere\Console\BuiltIn\ErrorHandler;
11+
use Inhere\Console\Component\ErrorHandler;
1212
use Inhere\Console\Face\ApplicationInterface;
1313
use Inhere\Console\Face\CommandInterface;
1414
use Inhere\Console\Face\ErrorHandlerInterface;
@@ -18,9 +18,9 @@
1818
use Inhere\Console\IO\OutputInterface;
1919
use Inhere\Console\Traits\InputOutputAwareTrait;
2020
use Inhere\Console\Traits\SimpleEventTrait;
21-
use Inhere\Console\Components\Style\Style;
22-
use Inhere\Console\Utils\FormatUtil;
23-
use Inhere\Console\Utils\Helper;
21+
use Inhere\Console\Component\Style\Style;
22+
use Inhere\Console\Util\FormatUtil;
23+
use Inhere\Console\Util\Helper;
2424

2525
/**
2626
* Class AbstractApplication
@@ -158,8 +158,9 @@ protected function beforeRun()
158158
}
159159

160160
/**
161-
* run app
161+
* run application
162162
* @param bool $exit
163+
* @return int|mixed
163164
* @throws \InvalidArgumentException
164165
*/
165166
public function run(bool $exit = true)
@@ -175,10 +176,10 @@ public function run(bool $exit = true)
175176

176177
// do run ...
177178
try {
178-
$returnCode = $this->dispatch($command);
179+
$result = $this->dispatch($command);
179180
} catch (\Throwable $e) {
180181
$this->fire(self::ON_RUN_ERROR, $e, $this);
181-
$returnCode = $e->getCode() === 0 ? $e->getLine() : $e->getCode();
182+
$result = $e->getCode() === 0 ? $e->getLine() : $e->getCode();
182183
$this->handleException($e);
183184
}
184185

@@ -189,8 +190,10 @@ public function run(bool $exit = true)
189190
$this->afterRun();
190191

191192
if ($exit) {
192-
$this->stop((int)$returnCode);
193+
$this->stop(\is_int($result) ? $result : 0);
193194
}
195+
196+
return $result;
194197
}
195198

196199
/**

0 commit comments

Comments
 (0)