Merge remote-tracking branch 'thom8/script_help'

main
Jordi Boggiano 7 years ago
commit 41a9357d4b

@ -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
a row like `@php install && @php foo`. You must split them up in a
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.

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

@ -228,7 +228,8 @@ class Application extends BaseApplication
if ($this->has($script)) {
$io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
} 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));
}
}
}

Loading…
Cancel
Save