Skip to content

Commit a254803

Browse files
committed
prof: add some useful methods
1 parent 257dd87 commit a254803

4 files changed

+25
-3
lines changed

src/Concern/CommandHelpTrait.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ trait CommandHelpTrait
3232
*/
3333
private $commentsVars;
3434

35+
/**
36+
* on display command help
37+
*
38+
* @var bool
39+
*/
40+
protected $renderGlobalOption = false;
41+
3542
/**
3643
* @return array
3744
*/
@@ -151,7 +158,7 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
151158
$this->beforeRenderCommandHelp($help);
152159

153160
// attached to console app
154-
if ($app = $this->getApp()) {
161+
if ($this->renderGlobalOption && ($app = $this->getApp())) {
155162
$help['Global Options:'] = FormatUtil::alignOptions($app->getFlags()->getOptsHelpLines());
156163
}
157164

@@ -170,4 +177,12 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
170177
protected function beforeRenderCommandHelp(array &$help): void
171178
{
172179
}
180+
181+
/**
182+
* @param bool $renderGlobalOption
183+
*/
184+
public function setRenderGlobalOption(bool $renderGlobalOption): void
185+
{
186+
$this->renderGlobalOption = $renderGlobalOption;
187+
}
173188
}

src/Concern/ControllerHelpTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function showCommandList(): void
121121
}
122122

123123
// is a annotation tag
124-
if (strpos($desc, '@') === 0) {
124+
if (str_starts_with($desc, '@')) {
125125
$desc = $defaultDes;
126126
}
127127

src/Concern/InputOutputAwareTrait.php

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public function getScript(): string
4646
return $this->input->getScriptFile();
4747
}
4848

49+
/**
50+
* @return string
51+
*/
52+
public function getWorkdir(): string
53+
{
54+
return $this->input->getWorkDir();
55+
}
56+
4957
/**
5058
* @return string
5159
*/

src/Controller.php

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
use function substr;
4141
use function trim;
4242
use function ucfirst;
43-
use function vdump;
4443

4544
/**
4645
* Class Controller

0 commit comments

Comments
 (0)