Skip to content

Commit

Permalink
prof: add some useful methods
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 6, 2021
1 parent 257dd87 commit a254803
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/Concern/CommandHelpTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ trait CommandHelpTrait
*/
private $commentsVars;

/**
* on display command help
*
* @var bool
*/
protected $renderGlobalOption = false;

/**
* @return array
*/
Expand Down Expand Up @@ -151,7 +158,7 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
$this->beforeRenderCommandHelp($help);

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

Expand All @@ -170,4 +177,12 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
protected function beforeRenderCommandHelp(array &$help): void
{
}

/**
* @param bool $renderGlobalOption
*/
public function setRenderGlobalOption(bool $renderGlobalOption): void
{
$this->renderGlobalOption = $renderGlobalOption;
}
}
2 changes: 1 addition & 1 deletion src/Concern/ControllerHelpTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function showCommandList(): void
}

// is a annotation tag
if (strpos($desc, '@') === 0) {
if (str_starts_with($desc, '@')) {
$desc = $defaultDes;
}

Expand Down
8 changes: 8 additions & 0 deletions src/Concern/InputOutputAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public function getScript(): string
return $this->input->getScriptFile();
}

/**
* @return string
*/
public function getWorkdir(): string
{
return $this->input->getWorkDir();
}

/**
* @return string
*/
Expand Down
1 change: 0 additions & 1 deletion src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use function substr;
use function trim;
use function ucfirst;
use function vdump;

/**
* Class Controller
Expand Down

0 comments on commit a254803

Please sign in to comment.