1111
1212use Toolkit \Cli \ColorTag ;
1313use Toolkit \Stdlib \Arr \ArrayHelper ;
14- use Toolkit \Stdlib \Helper \Format ;
1514use Toolkit \Stdlib \Helper \JsonHelper ;
1615use Toolkit \Stdlib \Str ;
1716use Toolkit \Sys \Sys ;
2524use function is_int ;
2625use function is_numeric ;
2726use function is_scalar ;
27+ use function preg_match ;
2828use function rtrim ;
2929use function str_repeat ;
3030use function str_replace ;
@@ -136,19 +136,22 @@ public static function wrapText(string $text, int $indent = 0, int $width = 0):
136136 }
137137
138138 /**
139+ * Align command option names.
140+ *
139141 * @param array $options
140142 *
141143 * @return array
144+ * @deprecated Please use {@see FlagUtil::alignOptions()}
142145 */
143146 public static function alignOptions (array $ options ): array
144147 {
145148 if (!$ options ) {
146149 return [];
147150 }
148151
149- // e.g '-h, --help'
150- $ hasShort = ( bool ) strpos ( implode ('' , array_keys ($ options )), ' , ' );
151- if (! $ hasShort ) {
152+ // check has short option. e.g '-h, --help'
153+ $ nameString = implode ('| ' , array_keys ($ options ));
154+ if (preg_match ( ' /\|-\w/ ' , $ nameString ) !== 1 ) {
152155 return $ options ;
153156 }
154157
@@ -171,34 +174,6 @@ public static function alignOptions(array $options): array
171174 return $ formatted ;
172175 }
173176
174- /**
175- * ```
176- * FormatUtil::memoryUsage(memory_get_usage(true));
177- * ```
178- *
179- * @param float|int $memory
180- *
181- * @return string
182- * @deprecated use Format::memory($secs);
183- */
184- public static function memoryUsage (float |int $ memory ): string
185- {
186- return Format::memory ($ memory );
187- }
188-
189- /**
190- * format timestamp to how long ago
191- *
192- * @param int $secs
193- *
194- * @return string
195- * @deprecated use Format::howLongAgo($secs);
196- */
197- public static function howLongAgo (int $ secs ): string
198- {
199- return Format::howLongAgo ($ secs );
200- }
201-
202177 /**
203178 * Splice array
204179 *
0 commit comments