Skip to content

Commit a15bec5

Browse files
committed
some udpate ... ...
1 parent d1feb5a commit a15bec5

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

src/AbstractCommand.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ abstract class AbstractCommand
2626
// please use the const setting current controller/command description
2727
const DESCRIPTION = '';
2828

29+
/**
30+
* TODO ...
31+
* command description message
32+
* please use the property setting current controller/command description
33+
* @var string
34+
*/
35+
public static $description = '';
36+
2937
/**
3038
* command name e.g 'test' 'test:one'
3139
* @var string
3240
*/
33-
private $name = '';
41+
public static $name = '';
3442

3543
/**
3644
* allow display message tags in the command
@@ -73,17 +81,17 @@ protected function handleRuntimeException(\Throwable $e)
7381
/**
7482
* @param string $name
7583
*/
76-
public function setName(string $name)
84+
public static function setName(string $name)
7785
{
78-
$this->name = $name;
86+
static::$name = $name;
7987
}
8088

8189
/**
8290
* @return string
8391
*/
84-
public function getName(): string
92+
public static function getName(): string
8593
{
86-
return $this->name;
94+
return static::$name;
8795
}
8896

8997
/**

src/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function runAction($name, $action, $believable = false)
141141
throw new \InvalidArgumentException("The console controller class [$object] must instanceof the " . Controller::class);
142142
}
143143

144-
$object->setName($name);
144+
$object::setName($name);
145145

146146
return $object->run($action);
147147
}

src/io/Output.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use inhere\console\Helper;
1212
use inhere\console\style\Style;
13-
use inhere\console\utils\Show;
1413
use inhere\console\utils\TraitFormatShow;
1514

1615
/**
@@ -59,21 +58,6 @@ public function read($question = null, $nl = false): string
5958
return trim(fgets(STDIN));
6059
}
6160

62-
/**
63-
* Write a message to standard output stream.
64-
* @param mixed $messages Output message
65-
* @param bool $nl true 会添加换行符 false 原样输出,不添加换行符
66-
* @param int|boolean $quit If is int, setting it is exit code.
67-
* @return integer
68-
*/
69-
public function write($messages = '', $nl = true, $quit = false): int
70-
{
71-
return Show::write($messages, $nl, $quit, [
72-
'flush' => true,
73-
'stream' => $this->outputStream,
74-
]);
75-
}
76-
7761
/**
7862
* Write a message to standard error output stream.
7963
* @param string $text

src/utils/Show.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,11 @@ public static function write($messages, $nl = true, $quit = false, array $opts =
683683
* @param string|array $text
684684
* @param array $opts
685685
* @param bool|int $quit
686+
* @return int
686687
*/
687688
public static function writeln($text, $quit = false, array $opts = [])
688689
{
689-
self::write($text, true, $quit, $opts);
690+
return self::write($text, true, $quit, $opts);
690691
}
691692

692693
/**

src/utils/TraitFormatShow.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@
1616
*/
1717
trait TraitFormatShow
1818
{
19+
/**
20+
* @inheritdoc
21+
* @see Show::write()
22+
*/
23+
public function write($messages = '', $nl = true, $quit = false): int
24+
{
25+
return Show::write($messages, $nl, $quit, [
26+
'flush' => true,
27+
'stream' => $this->outputStream,
28+
]);
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
* @see Show::writeln()
34+
*/
35+
public function writeln($text, $quit = false, array $opts = [])
36+
{
37+
return Show::writeln($text, $quit, $opts);
38+
}
39+
1940
/**
2041
* @inheritdoc
2142
* @see Show::title()

0 commit comments

Comments
 (0)