Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.4.2 |
Got an exception
When I run php my-script.php
.
Seems like a bug to me because no matter how I order the arguments the problem still occurs.
Expected:
Not enough arguments (missing: "invoice-id, customer").
Actual:
Cannot add a required argument after an optional one.
Caused by Symfony\Component\Console\Input\InputDefinition::addArgument
.
<?php
namespace Mite\Console;
use Mite\Mite;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class PdfCommand extends Command {
protected static $defaultName = 'mite:pdf';
protected function configure() {
// $this->addOption( 'month', 'm', InputOption::VALUE_OPTIONAL, 'Month which shall be invoiced', date( 'm' ) );
$this->addArgument( 'invoice-id', InputArgument::REQUIRED, 'ID of the invoice' );
$this->addArgument( 'customer', InputArgument::REQUIRED, 'Name of the customer as stored in mite' );
$this->addOption( 'month', 'm', InputOption::VALUE_OPTIONAL, 'Month which shall be invoiced', date( 'm' ) );
}
protected function execute( InputInterface $input, OutputInterface $output ) {
}
}
app.php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$app = new \Symfony\Component\Console\Application( 'mite-pdf' );
$app->addCommands( [
new \Mite\Console\PdfCommand(),
] );
$app->setDefaultCommand('mite:pdf');
$app->run();