13
13
14
14
use Symfony \Component \Console \Command \Command ;
15
15
use Symfony \Component \Console \Exception \RuntimeException ;
16
+ use Symfony \Component \Console \Input \InputArgument ;
16
17
use Symfony \Component \Console \Input \InputInterface ;
17
18
use Symfony \Component \Console \Input \InputOption ;
18
19
use Symfony \Component \Console \Output \OutputInterface ;
@@ -52,7 +53,7 @@ protected function configure()
52
53
{
53
54
$ this
54
55
->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 ' )
56
57
->addOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format ' , 'txt ' )
57
58
->setHelp (<<<EOF
58
59
The <info>%command.name%</info> command lints a XLIFF file and outputs to STDOUT
@@ -79,25 +80,27 @@ protected function configure()
79
80
protected function execute (InputInterface $ input , OutputInterface $ output )
80
81
{
81
82
$ io = new SymfonyStyle ($ input , $ output );
82
- $ filename = $ input ->getArgument ('filename ' );
83
+ $ filenames = ( array ) $ input ->getArgument ('filename ' );
83
84
$ this ->format = $ input ->getOption ('format ' );
84
85
$ this ->displayCorrectFiles = $ output ->isVerbose ();
85
86
86
- if (! $ filename ) {
87
+ if (0 === \count ( $ filenames ) ) {
87
88
if (!$ stdin = $ this ->getStdin ()) {
88
89
throw new RuntimeException ('Please provide a filename or pipe file content to STDIN. ' );
89
90
}
90
91
91
92
return $ this ->display ($ io , array ($ this ->validate ($ stdin )));
92
93
}
93
94
94
- if (!$ this ->isReadable ($ filename )) {
95
- throw new RuntimeException (sprintf ('File or directory "%s" is not readable. ' , $ filename ));
96
- }
97
-
98
95
$ 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
+ }
101
104
}
102
105
103
106
return $ this ->display ($ io , $ filesInfo );
0 commit comments