reset command

This commit is contained in:
grimhilt 2023-06-03 17:37:23 +02:00
parent eedb003d8c
commit 1a1b98729a
3 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,4 @@
pub mod init;
pub mod status;
pub mod add;
pub mod reset;

17
src/commands/reset.rs Normal file
View 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");
}
}

View File

@ -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();
}