[libra] 为 libra init 命令实现 [directory] 参数 #819
Merged
+129
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[标题] 为 libra init 命令实现 [directory] 参数
[任务简述]
Mega 项目是使用 Rust 编程语言开发的兼容 Git 的 Monorepo 引擎,其中的 libra 模块实现了 Git 客户端的部分功能,目前尚未支持所有 Git 子命令及参数。本任务将为 libra init 命令添加 [directory] 参数,以支持用户自定义仓库的创建目录。
[实现方案]
1.参考libra其他子命令的方式,在 InitArgs 结构体中添加 directory 参数,通过 Parse 库解析命令行参数
2.读取参数后,创建对应的 PathBuf,先判断该路径是否可以正常写入,不可写时返回对应的错误,可写时在目标路径创建仓库
3.在 libra init -h 命令中添加 [directory] 参数的帮助信息
4.为修改后的代码编写单元测试并运行通过