@@ -105,7 +105,9 @@ protected function configure(): void
105105 $ sortDescription = 'Sort from directories to files ' ;
106106
107107 $ alignExportIgnoresDescription = 'Align export-ignores on create or overwrite ' ;
108+ $ stdinInputDescription = "Read .gitattributes content from standard input " ;
108109
110+ $ this ->addOption ('stdin-input ' , null , InputOption::VALUE_NONE , $ stdinInputDescription );
109111 $ this ->addOption ('create ' , 'c ' , InputOption::VALUE_NONE , $ createDescription );
110112 $ this ->addOption (
111113 'enforce-strict-order ' ,
@@ -220,6 +222,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int
220222 }
221223 }
222224
225+ $ stdinInput = $ input ->getOption ('stdin-input ' );
226+
227+ if ($ stdinInput !== null ) {
228+ $ stdinContents = \file_get_contents ('php://stdin ' );
229+
230+ if (!strpos ($ stdinContents , 'export-ignore ' )) {
231+ $ warning = "Warning: The provided input stream seems to be no .gitattributes content. " ;
232+ $ outputContent = '<error> ' . $ warning . '</error> ' ;
233+ $ output ->writeln ($ outputContent );
234+
235+ return Command::FAILURE ;
236+ }
237+
238+
239+
240+
241+ return Command::SUCCESS ;
242+ }
243+
223244 $ verboseOutput = '+ Scanning directory ' . $ directory . '. ' ;
224245 $ output ->writeln ($ verboseOutput , OutputInterface::VERBOSITY_VERBOSE );
225246
@@ -301,8 +322,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
301322 return Command::FAILURE ;
302323 }
303324 }
304-
305-
325+
306326 $ alignExportIgnores = $ input ->getOption ('align-export-ignores ' );
307327
308328 if ($ alignExportIgnores ) {
0 commit comments