Start implementing thawing of repos

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
ATechnoHazard 2020-10-20 18:12:45 +05:30
parent 972daa40f2
commit 1bcbccf30b
No known key found for this signature in database
GPG key ID: F475143EDEDEBA3C

View file

@ -10,14 +10,26 @@ struct PersistableRepo {
} }
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
let dir = match std::env::args().nth(1) { let dir = match std::env::args().nth(2) {
Some(d) => d, Some(d) => d,
None => { None => {
println!("Usage:\n gitice <dir>\n"); println!("Usage:\n gitice <command> <dir>\n");
return Ok(()); return Ok(());
} }
}; };
// temporary solution to support both freezing and thawing
match std::env::args().nth(1).as_ref().map(|s| &s[..]) {
Some("freeze") => freeze_repos(dir),
Some("thaw") => thaw_repos(dir),
_ => {
println!("Usage:\n gitice <command> <dir>\n");
Ok(())
}
}
}
fn freeze_repos(dir: String) -> anyhow::Result<()> {
let mut repos: HashMap<String, PersistableRepo> = HashMap::new(); let mut repos: HashMap<String, PersistableRepo> = HashMap::new();
for entry in WalkDir::new(dir.clone()).into_iter().filter_map(|e| e.ok()) { for entry in WalkDir::new(dir.clone()).into_iter().filter_map(|e| e.ok()) {
if entry.file_type().is_dir() { if entry.file_type().is_dir() {
@ -60,3 +72,7 @@ fn main() -> anyhow::Result<()> {
fs::write("gitice.lock", toml::to_string(&repos)?).expect("could not write to lockfile!"); fs::write("gitice.lock", toml::to_string(&repos)?).expect("could not write to lockfile!");
Ok(()) Ok(())
} }
fn thaw_repos(_dir: String) -> anyhow::Result<()> {
Ok(())
}