1
0
Fork 0

Merge remote-tracking branch 'thom8/script_help'

pull/6734/merge
Jordi Boggiano 2017-11-03 17:19:36 +01:00
commit 41a9357d4b
3 changed files with 22 additions and 3 deletions

View File

@ -271,3 +271,19 @@ resolve to whatever php process is currently being used:
One limitation of this is that you can not call multiple commands in One limitation of this is that you can not call multiple commands in
a row like `@php install && @php foo`. You must split them up in a a row like `@php install && @php foo`. You must split them up in a
JSON array of commands. JSON array of commands.
## Custom descriptions.
You can set custom script descriptions with the following extra in your composer.json:
```json
{
"extra": {
"scripts-description": {
"test": "Run all tests!"
}
}
}
```
> **Note:** You can only set custom descriptions of custom commands.

View File

@ -23,10 +23,12 @@ use Symfony\Component\Console\Output\OutputInterface;
class ScriptAliasCommand extends BaseCommand class ScriptAliasCommand extends BaseCommand
{ {
private $script; private $script;
private $description;
public function __construct($script) public function __construct($script, $description)
{ {
$this->script = $script; $this->script = $script;
$this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
parent::__construct(); parent::__construct();
} }
@ -35,7 +37,7 @@ class ScriptAliasCommand extends BaseCommand
{ {
$this $this
->setName($this->script) ->setName($this->script)
->setDescription('Runs the '.$this->script.' script as defined in composer.json.') ->setDescription($this->description)
->setDefinition(array( ->setDefinition(array(
new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'), new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'), new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),

View File

@ -228,7 +228,8 @@ class Application extends BaseApplication
if ($this->has($script)) { if ($this->has($script)) {
$io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>'); $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
} else { } else {
$this->add(new Command\ScriptAliasCommand($script)); $description = isset($composer['extra']['scripts-description'][$script]) ? $composer['extra']['scripts-description'][$script]:NULL;
$this->add(new Command\ScriptAliasCommand($script, $description));
} }
} }
} }