|
14 | 14 | useSymfony\Component\Console\Command\Command; |
15 | 15 | useSymfony\Component\Console\Exception\InvalidArgumentException; |
16 | 16 | useSymfony\Component\Console\Exception\RuntimeException; |
| 17 | +useSymfony\Component\Console\Input\InputArgument; |
17 | 18 | useSymfony\Component\Console\Input\InputInterface; |
18 | 19 | useSymfony\Component\Console\Input\InputOption; |
19 | 20 | useSymfony\Component\Console\Output\OutputInterface; |
@@ -53,7 +54,7 @@ protected function configure() |
53 | 54 | { |
54 | 55 | $this |
55 | 56 | ->setDescription('Lints a file and outputs encountered errors') |
56 | | - ->addArgument('filename',null,'A file or a directory or STDIN') |
| 57 | + ->addArgument('filename',InputArgument::IS_ARRAY,'A file or a directory or STDIN') |
57 | 58 | ->addOption('format',null, InputOption::VALUE_REQUIRED,'The output format','txt') |
58 | 59 | ->addOption('parse-tags',null, InputOption::VALUE_NONE,'Parse custom tags') |
59 | 60 | ->setHelp(<<<EOF |
@@ -81,26 +82,28 @@ protected function configure() |
81 | 82 | protectedfunctionexecute(InputInterface$input,OutputInterface$output) |
82 | 83 | { |
83 | 84 | $io =newSymfonyStyle($input,$output); |
84 | | -$filename =$input->getArgument('filename'); |
| 85 | +$filenames = (array)$input->getArgument('filename'); |
85 | 86 | $this->format =$input->getOption('format'); |
86 | 87 | $this->displayCorrectFiles =$output->isVerbose(); |
87 | 88 | $flags =$input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS :0; |
88 | 89 |
|
89 | | -if (!$filename) { |
| 90 | +if (0 ===\count($filenames)) { |
90 | 91 | if (!$stdin =$this->getStdin()) { |
91 | 92 | thrownewRuntimeException('Please provide a filename or pipe file content to STDIN.'); |
92 | 93 | } |
93 | 94 |
|
94 | 95 | return$this->display($io,array($this->validate($stdin,$flags))); |
95 | 96 | } |
96 | 97 |
|
97 | | -if (!$this->isReadable($filename)) { |
98 | | -thrownewRuntimeException(sprintf('File or directory "%s" is not readable.',$filename)); |
99 | | - } |
100 | | - |
101 | 98 | $filesInfo =array(); |
102 | | -foreach ($this->getFiles($filename)as$file) { |
103 | | -$filesInfo[] =$this->validate(file_get_contents($file),$flags,$file); |
| 99 | +foreach ($filenamesas$filename) { |
| 100 | +if (!$this->isReadable($filename)) { |
| 101 | +thrownewRuntimeException(sprintf('File or directory "%s" is not readable.',$filename)); |
| 102 | + } |
| 103 | + |
| 104 | +foreach ($this->getFiles($filename)as$file) { |
| 105 | +$filesInfo[] =$this->validate(file_get_contents($file),$flags,$file); |
| 106 | + } |
104 | 107 | } |
105 | 108 |
|
106 | 109 | return$this->display($io,$filesInfo); |
|