4646use function explode ;
4747use function getcwd ;
4848
49+ use const PHP_EOL ;
50+
4951/**
5052 * Provides the `formatphp extract` command
5153 */
@@ -78,100 +80,107 @@ protected function configure(): void
7880 ->addArgument (
7981 'files ' ,
8082 InputArgument::OPTIONAL | InputArgument::IS_ARRAY ,
81- 'One or more paths to process for extraction. May use glob '
82- . 'patterns for file matching; supports globstar (`**`) '
83- . 'for recursive matching. ' ,
83+ 'One or more paths to process for extraction. ' . PHP_EOL
84+ . 'May use glob patterns for file matching;' . PHP_EOL
85+ . 'supports globstar (**) for recursive matching. ' ,
8486 )
8587 ->addOption (
86- 'format ' ,
88+ '-- format ' ,
8789 null ,
8890 InputOption::VALUE_REQUIRED ,
89- 'Formatter name or path to a formatter script that controls '
90- . 'the shape of the JSON produced for `--out-file`. ' ,
91+ 'Formatter name or path to a formatter script ' . PHP_EOL
92+ . 'that controls the shape of the JSON produced ' . PHP_EOL
93+ . 'for `--out-file`. ' ,
9194 )
9295 ->addOption (
93- 'out-file ' ,
96+ '-- out-file ' ,
9497 null ,
9598 InputOption::VALUE_REQUIRED ,
96- 'Target file path to save the JSON output file of all '
97- . 'translations extracted from the `files`. ' ,
99+ 'Target file path to save the JSON output file ' . PHP_EOL
100+ . 'of all translations extracted from the `files`. ' ,
98101 )
99102 ->addOption (
100- 'id-interpolation-pattern ' ,
103+ '--ignore ' ,
101104 null ,
102- InputOption::VALUE_REQUIRED ,
103- 'If message descriptors are missing the id property, we will '
104- . 'use this pattern to automatically generate IDs for '
105- . 'them. Defaults to `[sha512:contenthash:base64:6]` where '
106- . '`contenthash` represents the hash of `defaultMessage` '
107- . 'and `description`. ' ,
105+ InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED ,
106+ 'Glob patterns for paths to exclude from ' . PHP_EOL
107+ . 'extraction. ' ,
108108 )
109109 ->addOption (
110- 'extract-source-location ' ,
110+ '--flatten ' ,
111111 null ,
112112 InputOption::VALUE_NONE ,
113- 'Whether to extract metadata for the source files. If present, '
114- . 'the extracted descriptors will each include `file`, '
115- . '`start`, `end`, `line`, and `col` properties. ' ,
113+ 'Whether to hoist selectors & flatten sentences ' . PHP_EOL
114+ . 'as much as possible, e.g: "I have {count, ' . PHP_EOL
115+ . 'plural, one{a dog} other{many dogs}}" becomes ' . PHP_EOL
116+ . '"{count, plural, one{I have a dog} other{I have ' . PHP_EOL
117+ . 'many dogs}}". The goal is to provide as many ' . PHP_EOL
118+ . 'full sentences as possible, since fragmented ' . PHP_EOL
119+ . 'sentences are not translator-friendly. ' ,
116120 )
117121 ->addOption (
118- 'additional-function-names ' ,
122+ '--extract-source-location ' ,
119123 null ,
120- InputOption::VALUE_REQUIRED ,
121- 'Comma-separated list of additional function names to search '
122- . 'for when extracting messages. ' ,
124+ InputOption::VALUE_NONE ,
125+ 'Whether to extract source file metadata. If ' . PHP_EOL
126+ . 'present, the extracted descriptors will each ' . PHP_EOL
127+ . 'include `file`, `start`, `end`, `line`, and ' . PHP_EOL
128+ . '`col` properties. ' ,
123129 )
124130 ->addOption (
125- 'parser ' ,
126- ' p ' ,
127- InputOption::VALUE_IS_ARRAY | InputOption:: VALUE_REQUIRED ,
128- 'Parser name or path to a parser script to apply additional '
129- . 'parsing in addition to the default PHP parsing . ' ,
131+ '--addl-func ' ,
132+ null ,
133+ InputOption::VALUE_REQUIRED ,
134+ 'Comma-separated list of additional function ' . PHP_EOL
135+ . 'names to search for when extracting messages . ' ,
130136 )
131137 ->addOption (
132- 'ignore ' ,
138+ '--pragma ' ,
133139 null ,
134- InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED ,
135- 'Glob patterns for paths to exclude from extraction. ' ,
140+ InputOption::VALUE_REQUIRED ,
141+ 'Allows parsing of additional custom pragma to ' . PHP_EOL
142+ . 'include custom metadata in the extracted ' . PHP_EOL
143+ . 'messages. ' ,
136144 )
137145 ->addOption (
138- 'throws ' ,
146+ '--preserve-whitespace ' ,
139147 null ,
140148 InputOption::VALUE_NONE ,
141- 'Whether to throw an exception when failing to process any '
142- . 'file in the batch . ' ,
149+ 'Whether to preserve whitespace and newlines in ' . PHP_EOL
150+ . 'extracted messages . ' ,
143151 )
144152 ->addOption (
145- 'pragma ' ,
146- null ,
147- InputOption::VALUE_REQUIRED ,
148- 'Allows parsing of additional custom pragma to include custom '
149- . 'metadata in the extracted messages. ' ,
153+ '--parser ' ,
154+ '-p ' ,
155+ InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED ,
156+ 'Parser name or path to a parser script to apply ' . PHP_EOL
157+ . 'additional parsing in addition to the default ' . PHP_EOL
158+ . 'PHP parsing. ' ,
150159 )
151160 ->addOption (
152- 'preserve-whitespace ' ,
161+ '--throws ' ,
153162 null ,
154163 InputOption::VALUE_NONE ,
155- 'Whether to preserve whitespace and newlines in extracted '
156- . 'messages . ' ,
164+ 'Whether to throw an exception when failing to ' . PHP_EOL
165+ . 'process any file in the batch . ' ,
157166 )
158167 ->addOption (
159- 'flatten ' ,
168+ '--id-pattern ' ,
160169 null ,
161- InputOption::VALUE_NONE ,
162- 'Whether to hoist selectors & flatten sentences as much as possible, '
163- . 'e.g: "I have {count, plural, one{a dog} other{many dogs}}" '
164- . 'becomes "{count, plural, one{I have a dog} other{I have many '
165- . 'dogs}}". The goal is to provide as many full sentences as '
166- . 'possible, since fragmented sentences are not translator-friendly . ' ,
170+ InputOption::VALUE_REQUIRED ,
171+ 'If message descriptors are missing the id ' . PHP_EOL
172+ . 'property, we will use this to autogenerate IDs. ' . PHP_EOL
173+ . 'Defaults to `[sha512:contenthash:base64:6]` ' . PHP_EOL
174+ . 'where `contenthash` represents the hash of ' . PHP_EOL
175+ . '`defaultMessage` and `description` . ' ,
167176 )
168177 ->addOption (
169- 'add-missing-ids ' ,
178+ '-- add-missing-ids ' ,
170179 null ,
171180 InputOption::VALUE_NONE ,
172- 'Whether to update the source code in place with autogenerated '
173- . 'descriptor IDs. Descriptors that already have IDs will '
174- . 'remain untouched . ' ,
181+ 'Whether to update the source code in place with ' . PHP_EOL
182+ . 'autogenerated descriptor IDs. Descriptors that' . PHP_EOL
183+ . 'already have IDs will not change . ' ,
175184 );
176185 }
177186
@@ -220,7 +229,7 @@ private function buildOptions(InputInterface $input): MessageExtractorOptions
220229 $ options ->outFile = $ outFile ;
221230
222231 /** @var string | null $idInterpolationPattern */
223- $ idInterpolationPattern = $ input ->getOption ('id-interpolation- pattern ' );
232+ $ idInterpolationPattern = $ input ->getOption ('id-pattern ' );
224233 $ options ->idInterpolationPattern = $ idInterpolationPattern ?? IdInterpolator::DEFAULT_ID_INTERPOLATION_PATTERN ;
225234
226235 /** @var string[] $parsers */
@@ -242,7 +251,7 @@ private function buildOptions(InputInterface $input): MessageExtractorOptions
242251 $ options ->addGeneratedIdsToSourceCode = (bool ) $ input ->getOption ('add-missing-ids ' );
243252
244253 /** @var string $inputFunctionNames */
245- $ inputFunctionNames = $ input ->getOption ('additional-function-names ' ) ?? '' ;
254+ $ inputFunctionNames = $ input ->getOption ('addl-func ' ) ?? '' ;
246255 $ additionalFunctionNames = array_map ('trim ' , explode (', ' , $ inputFunctionNames ));
247256 $ options ->functionNames = array_unique (array_merge ($ options ->functionNames , $ additionalFunctionNames ));
248257
0 commit comments