я хотел бы добавить параметры на основе аргумента в моей команде импорта. Я думал, что это может сработать, чтобы добавить их в взаимодействие(), но когда я запускаю
bin/console app:import test --supplier=5
я получил
[Symfony\Component\Console\Exception\RuntimeException]
Параметр "--supplier" не существует.
Я знаю, что мог бы использовать вопросы, но я бы предпочел варианты, потому что это избавляет меня от необходимости периодически запускать команду импорта! Вот моя команда:
class ImportCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('app:import')
->addArgument('importKey', InputArgument::REQUIRED)
;
}
protected function interact(InputInterface $input, OutputInterface $output)
{
$key = $input->getArgument('importKey');
// this will be handled in
// $importProvider = $this->getContainer()->get('app.import.provider');
// $importer = $importProvider->getImport($key);
// $importer->configureCommand($input, $output, $this);
// but for simplicity's sake
if($key == 'test')
{
$this->addOption('supplier', null,InputOption::VALUE_REQUIRED);
}
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$supplier = $input->getOption('supplier');
$output->writeln("your provided suplier id is '$supplier'");
}
}