mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 11:47:01 +05:30
Start implementing thawing of repos
Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
parent
972daa40f2
commit
1bcbccf30b
1 changed files with 18 additions and 2 deletions
20
src/main.rs
20
src/main.rs
|
@ -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(())
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue