start add command
This commit is contained in:
18
src/commands/add.rs
Normal file
18
src/commands/add.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user