argument('path'); if (! is_file($path) || ! is_readable($path)) { throw new RuntimeException('账户简称批量修改文件不存在或不可读取。'); } if (strtolower(pathinfo($path, PATHINFO_EXTENSION)) !== 'json') { throw new RuntimeException('账户简称批量修改文件必须为 JSON。'); } if (filesize($path) > 10 * 1024 * 1024) { throw new RuntimeException('账户简称批量修改文件不能超过 10 MB。'); } $content = file_get_contents($path); if (! is_string($content)) { throw new RuntimeException('无法读取账户简称批量修改文件。'); } $mappings = json_decode($content, true, 512, JSON_THROW_ON_ERROR); if (! is_array($mappings) || ! array_is_list($mappings)) { throw new RuntimeException('账户简称批量修改文件必须是 JSON 数组。'); } $apply = (bool) $this->option('apply'); $result = $editor->renameShorts($mappings, $apply); } catch (Throwable $exception) { $this->error($exception->getMessage()); return self::FAILURE; } $this->info(sprintf( '%s账户简称:共 %d 户,计划修改 %d 户,未变化 %d 户。', $result['dry_run'] ? '校验完成,' : '已完成', $result['requested'], $result['changed'], $result['unchanged'], )); return self::SUCCESS; } }