reset command
This commit is contained in:
parent
eedb003d8c
commit
1a1b98729a
@ -1,3 +1,4 @@
|
||||
pub mod init;
|
||||
pub mod status;
|
||||
pub mod add;
|
||||
pub mod reset;
|
||||
|
17
src/commands/reset.rs
Normal file
17
src/commands/reset.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use std::fs::File;
|
||||
use crate::utils;
|
||||
|
||||
pub fn reset() {
|
||||
let mut root = match utils::path::nextsync_root() {
|
||||
Some(path) => path,
|
||||
None => {
|
||||
eprintln!("fatal: not a nextsync repository (or any of the parent directories): .nextsync");
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
root.push(".nextsync");
|
||||
root.push("index");
|
||||
if File::create(root).is_err() {
|
||||
eprintln!("fatal: failed to reset");
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ fn main() {
|
||||
.about("")
|
||||
.subcommand(SubCommand::with_name("init"))
|
||||
.subcommand(SubCommand::with_name("status"))
|
||||
.subcommand(SubCommand::with_name("reset"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("add")
|
||||
.arg(
|
||||
@ -37,6 +38,8 @@ fn main() {
|
||||
if let Some(files) = matches.values_of("files") {
|
||||
commands::add::add(files);
|
||||
}
|
||||
} else if let Some(_) = matches.subcommand_matches("reset") {
|
||||
commands::reset::reset();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user