diff --git a/src/cli.rs b/src/cli.rs
index d2c2f9a..80b8738 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -9,18 +9,24 @@ struct Cli {
#[clap(subcommand)]
command: Command,
}
-
+/// @see Rust Clap库学习 - 掘金
#[derive(Subcommand)]
enum Command {
/// 初始化仓库
Init,
/// 添加文件到暂存区
+ /// @see git add .,git add -A,git add -u,git add * 的区别与联系
Add {
/// 要添加的文件
files: Vec,
- #[clap(short, long)]
+ /// 将工作区中所有的文件改动提交至暂存区(包括新增、修改和删除)
+ #[clap(short = 'A', long)]
all: bool,
+
+ /// 将工作区中已跟踪的文件(tracked)更新到暂存区(修改 & 删除);But不包含新增
+ #[clap(short, long)]
+ update: bool,
},
/// 删除文件
Rm {
@@ -45,7 +51,7 @@ pub fn handle_command() {
Command::Init => {
let _ = init();
}
- Command::Add { files , all } => {
+ Command::Add { files , all, update} => {
if files.contains(&".".to_string()) || all {
println!("add all files");
} else {
diff --git a/src/commands/init.rs b/src/commands/init.rs
index deca19b..6556afd 100644
--- a/src/commands/init.rs
+++ b/src/commands/init.rs
@@ -2,8 +2,8 @@ use std::{env, fs, io};
/**
初始化mit仓库 创建.mit/objects .mit/refs/heads .mit/HEAD
-并设置 .mit 为隐藏文件夹
-无法重复初始化
+
并设置 .mit 为隐藏文件夹
+
无法重复初始化
*/
pub fn init() -> io::Result<()> {
let dir = env::current_dir()?;