Skip to content

Commit cd2b998

Browse files
committed
upsome for alone run command
1 parent db4a1ca commit cd2b998

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

src/AbstractHandler.php

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,33 @@ abstract class AbstractHandler implements CommandHandlerInterface
9393
'help' => true,
9494
];
9595

96-
/** @var Application */
96+
/**
97+
* @var Application
98+
*/
9799
protected $app;
98100

99-
/** @var InputDefinition|null */
101+
/**
102+
* @var InputDefinition|null
103+
*/
100104
private $definition;
101105

102-
/** @var string */
106+
/**
107+
* @var string
108+
*/
103109
private $processTitle = '';
104110

105-
/** @var array */
111+
/**
112+
* @var array
113+
*/
106114
private $commentsVars;
107115

116+
/**
117+
* Mark the command/controller is attached in application.
118+
*
119+
* @var bool
120+
*/
121+
private $attached = true;
122+
108123
/**
109124
* Whether enabled
110125
*
@@ -545,8 +560,15 @@ protected function showHelp(): bool
545560
}
546561
}
547562

563+
$binName = $this->getScriptName();
564+
548565
// build usage
549-
$help['usage:'] = sprintf('%s %s %s', $this->getScriptName(), $this->getCommandName(), $help['usage:']);
566+
if ($this->attached) {
567+
$help['usage:'] = sprintf('%s %s %s', $binName, $this->getCommandName(), $help['usage:']);
568+
} else {
569+
$help['usage:'] = $binName . ' ' . $help['usage:'];
570+
}
571+
550572
// align global options
551573
$help['global options:'] = FormatUtil::alignOptions(Application::getGlobalOptions());
552574

@@ -820,6 +842,22 @@ public function setApp(AbstractApplication $app): void
820842
$this->app = $app;
821843
}
822844

845+
/**
846+
* @return bool
847+
*/
848+
public function isAttached(): bool
849+
{
850+
return $this->attached;
851+
}
852+
853+
/**
854+
* @param bool $attached
855+
*/
856+
public function setAttached(bool $attached): void
857+
{
858+
$this->attached = $attached;
859+
}
860+
823861
/**
824862
* @return string
825863
*/

0 commit comments

Comments
 (0)