start add command

This commit is contained in:
grimhilt
2023-06-01 23:58:23 +02:00
parent 04bef223a3
commit f1724d23f5
5 changed files with 46 additions and 5 deletions

18
src/commands/add.rs Normal file
View File

@@ -0,0 +1,18 @@
use clap::Values;
use crate::utils;
pub fn add(files: Values<'_>) {
let 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);
}
};
dbg!(root.clone());
let file_vec: Vec<&str> = files.collect();
for file in file_vec {
println!("{}", file);
}
}

View File

@@ -18,6 +18,13 @@ pub fn init() {
Err(_) => println!("Error: cannot create .nextsyncignore"),
}
path.pop();
path.push("index");
match File::create(path.clone()) {
Ok(_) => println!("File successfuly created"),
Err(_) => println!("Error: cannot create .nextsyncignore"),
}
path.pop();
path.pop();
path.push(".nextsyncignore");
@@ -26,5 +33,4 @@ pub fn init() {
Ok(_) => println!("File successfuly created"),
Err(_) => println!("Error: cannot create .nextsyncignore"),
}
}

View File

@@ -9,9 +9,8 @@ use std::collections::HashSet;
use colored::Colorize;
use std::fs;
// todo: relative path, filename
// todo: relative path, filename, get modified
pub fn status() {
let mut new_files: Vec<PathBuf> = Vec::new();
let mut hashes = HashSet::new();
let mut objects: Vec<String> = vec![];
@@ -102,7 +101,7 @@ fn read_folder(path: PathBuf) -> io::Result<Vec<PathBuf>> {
let mut entries = fs::read_dir(path)?
.map(|res| res.map(|e| e.path()))
.collect::<Result<Vec<_>, io::Error>>()?;
entries.sort();
Ok(entries)
}