1313
1414use Symfony \Component \Console \Command \Command ;
1515use Symfony \Component \Console \Exception \RuntimeException ;
16+ use Symfony \Component \Console \Input \InputArgument ;
1617use Symfony \Component \Console \Input \InputInterface ;
1718use Symfony \Component \Console \Input \InputOption ;
1819use Symfony \Component \Console \Output \OutputInterface ;
@@ -52,7 +53,7 @@ protected function configure()
5253 {
5354 $ this
5455 ->setDescription ('Lints a XLIFF file and outputs encountered errors ' )
55- ->addArgument ('filename ' , null , 'A file or a directory or STDIN ' )
56+ ->addArgument ('filename ' , InputArgument:: IS_ARRAY , 'A file or a directory or STDIN ' )
5657 ->addOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format ' , 'txt ' )
5758 ->setHelp (<<<EOF
5859The <info>%command.name%</info> command lints a XLIFF file and outputs to STDOUT
@@ -79,25 +80,27 @@ protected function configure()
7980 protected function execute (InputInterface $ input , OutputInterface $ output )
8081 {
8182 $ io = new SymfonyStyle ($ input , $ output );
82- $ filename = $ input ->getArgument ('filename ' );
83+ $ filenames = ( array ) $ input ->getArgument ('filename ' );
8384 $ this ->format = $ input ->getOption ('format ' );
8485 $ this ->displayCorrectFiles = $ output ->isVerbose ();
8586
86- if (! $ filename ) {
87+ if (0 === \count ( $ filenames ) ) {
8788 if (!$ stdin = $ this ->getStdin ()) {
8889 throw new RuntimeException ('Please provide a filename or pipe file content to STDIN. ' );
8990 }
9091
9192 return $ this ->display ($ io , array ($ this ->validate ($ stdin )));
9293 }
9394
94- if (!$ this ->isReadable ($ filename )) {
95- throw new RuntimeException (sprintf ('File or directory "%s" is not readable. ' , $ filename ));
96- }
97-
9895 $ filesInfo = array ();
99- foreach ($ this ->getFiles ($ filename ) as $ file ) {
100- $ filesInfo [] = $ this ->validate (file_get_contents ($ file ), $ file );
96+ foreach ($ filenames as $ filename ) {
97+ if (!$ this ->isReadable ($ filename )) {
98+ throw new RuntimeException (sprintf ('File or directory "%s" is not readable. ' , $ filename ));
99+ }
100+
101+ foreach ($ this ->getFiles ($ filename ) as $ file ) {
102+ $ filesInfo [] = $ this ->validate (file_get_contents ($ file ), $ file );
103+ }
101104 }
102105
103106 return $ this ->display ($ io , $ filesInfo );
0 commit comments