Closed
Description
Description
Custom Application-level options not shown when error and has potentially be missed by the user.
When the dev adding options by extending the default InputDefinition
like the following,
$application = new Application();
$inputdef = $application->getDefinition();
$inputdef->addOption(new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to configuration file'));
$inputdef->addOption(new InputOption('profile', 'p', InputOption::VALUE_REQUIRED, 'Profile to use (the env filename without extension)'));
$application->setDefinition($inputdef);
It's only shown in one place, the top level command (application) --help
. There is nothing that makes the user aware when executing sub-command that top-level options are available. It had be nice if there is some kind of notice or even showing up the options in sub-command help / synopsis. Because symfony
doesn't support putting option before command:
# Not okay
./bin/example --config example.config.php create helloworld
# Okay
./bin/example create --config example.config.php helloworld
Example
Sub-command help add long list of options:
Usage:
up [options]
Options:
--to=TO Migration will be uped up to this migration id included
--only=ONLY If you need to up this migration id only
--changelog-only Mark as applied without executing SQL
Top-level Options:
--config=CONFIG Migration will be uped up to this migration id included
--profile=PROFILE If you need to up this migration id only
--the-default-options-more More..
Help:
Execute all waiting migration up to [to] option if precised
When sub-command errors add some notice,
[Symfony\Component\Console\Exception\InvalidArgumentException]
The "bingbong" option does not exist.
up [--to TO] [--only ONLY] [--changelog-only]
There are also top-level options available.