|
9 | 9 | $cliOptions = new class extends CliOptionsParser { |
10 | 10 | public string $action; |
11 | 11 | public string $key; |
| 12 | + public string $newKey; |
12 | 13 | public string $value; |
13 | 14 | public string $language; |
14 | 15 | public string $originLanguage; |
|
18 | 19 | public function __construct() { |
19 | 20 | $this->addRequiredOption('action', (new CliOption('action', 'a'))); |
20 | 21 | $this->addOption('key', (new CliOption('key', 'k'))); |
| 22 | + $this->addOption('newKey', (new CliOption('new-key', 'n'))); |
21 | 23 | $this->addOption('value', (new CliOption('value', 'v'))); |
22 | 24 | $this->addOption('language', (new CliOption('language', 'l'))); |
23 | 25 | $this->addOption('originLanguage', (new CliOption('origin-language', 'o'))); |
@@ -56,6 +58,14 @@ public function __construct() { |
56 | 58 | exit; |
57 | 59 | } |
58 | 60 | break; |
| 61 | + case 'move': |
| 62 | + if (isset($cliOptions->key) && isset($cliOptions->newKey)) { |
| 63 | + $i18nData->moveKey($cliOptions->key, $cliOptions->newKey); |
| 64 | + } else { |
| 65 | + error('You need to specify the key to move and its new location.'); |
| 66 | + exit; |
| 67 | + } |
| 68 | + break; |
59 | 69 | case 'delete': |
60 | 70 | if (isset($cliOptions->key)) { |
61 | 71 | $i18nData->removeKey($cliOptions->key); |
@@ -131,7 +141,7 @@ function manipulateHelp(): void { |
131 | 141 | Manipulate translation files. |
132 | 142 |
|
133 | 143 | -a, --action=ACTION |
134 | | - select the action to perform. Available actions are add, delete, |
| 144 | + select the action to perform. Available actions are add, move, delete, |
135 | 145 | exist, format, ignore, and ignore_unmodified. This option is mandatory. |
136 | 146 | -k, --key=KEY select the key to work on. |
137 | 147 | -v, --value=VAL select the value to set. |
@@ -176,6 +186,9 @@ function manipulateHelp(): void { |
176 | 186 |
|
177 | 187 | Example 11: add a new file to all languages |
178 | 188 | php $file -a add -k my_file.php |
179 | | -HELP; |
| 189 | +
|
| 190 | +Example 12:\tmove an existing key into a new location |
| 191 | + php $file -a move -k my_key -n new_location |
| 192 | +HELP, PHP_EOL; |
180 | 193 | exit(); |
181 | 194 | } |
0 commit comments