feat(debug): 支持 --new 参数创建全新调试存档

添加  选项,启动调试时自动生成带时间戳的新存档目录
(格式 MC_DEV_WORLD_YYYYMMDD_HHMMSS)并持久化到 .mcdev.json。

- 新增 local_timestamp_compact() 跨平台本地时间格式化
- 新增 allocate_new_world() 更新配置并落盘
- 补充单元测试验证存档名格式与持久化正确性
This commit is contained in:
2026-05-16 17:24:13 +08:00
parent 011b59c948
commit fd79a99477
6 changed files with 140 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ pub fn execute(args: &DebugArgs) {
.map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from("."));
if let Err(err) = debug::run(&project_dir) {
if let Err(err) = debug::run(&project_dir, args.new_world) {
eprintln!("Error: {}", err);
}
}

View File

@@ -92,4 +92,7 @@ pub struct DebugArgs {
/// The path of the project (default: current directory)
#[arg(short, long)]
pub path: Option<String>,
/// Create a fresh debug world and persist it in .mcdev.json
#[arg(short = 'n', long = "new")]
pub new_world: bool,
}