addArgument( 'file', InputArgument::REQUIRED, 'The file to read', null, new FileValidator( /** @lang PhpRegExp */ '#\.txt$#i', FilesystemValidationOption::IsReadable ) ); } /** * @inheritDoc */ protected function execute (InputInterface $input, OutputInterface $output): int { if (($fileContent = file_get_contents($input->getArgument('file'))) === false) { return Command::FAILURE; } $output->writeln($fileContent); return Command::SUCCESS; } }