MCPcopy Create free account
hub / github.com/MrBeanCpp/MIT / handle_command

Function handle_command

src/cli.rs:123–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121 },
122}
123pub fn handle_command() {
124 let cli = Cli::parse();
125 match cli.command {
126 Command::Init => {
127 cmd::init().expect("初始化失败");
128 }
129 Command::Add { files, all, update } => {
130 cmd::add(files, all, update);
131 }
132 Command::Rm { files, cached, recursive } => {
133 cmd::rm(files, cached, recursive).expect("删除失败");
134 }
135 Command::Commit { message, allow_empty } => {
136 cmd::commit(message, allow_empty);
137 }
138 Command::Status => {
139 cmd::status();
140 }
141 Command::Log { all, number } => {
142 cmd::log(all, number);
143 }
144 Command::Branch { list, delete, new_branch, commit_hash, show_current } => {
145 cmd::branch(new_branch, commit_hash, list, delete, show_current);
146 }
147 Command::Switch { branch, create, detach } => {
148 cmd::switch(branch, create, detach);
149 }
150 Command::Restore { path, source, mut worktree, staged } => {
151 // 未指定stage和worktree时,默认操作worktree
152 // 指定 --staged 将仅还原index
153 if !staged {
154 worktree = true;
155 }
156 // 未指定source 且 --staged,默认操作HEAD,否则从index中恢复(就近原则)
157 /*
158 If `--source` not specified, the contents are restored from `HEAD` if `--staged` is given,
159 otherwise from the [index].
160 */
161 cmd::restore(path, source, worktree, staged);
162 }
163 Command::Merge { branch } => {
164 cmd::merge(branch);
165 }
166 }
167}

Callers 1

mainFunction · 0.85

Calls 9

initFunction · 0.85
addFunction · 0.85
commitFunction · 0.85
statusFunction · 0.85
logFunction · 0.85
branchFunction · 0.85
switchFunction · 0.85
restoreFunction · 0.85
mergeFunction · 0.85

Tested by

no test coverage detected