use directories::UserDirs; use std::path::PathBuf; fn main() { match remotes() { Ok(_) => {} Err(e) => panic!("{}", e), } } fn remotes() -> std::result::Result<(), Box> { println!("remotes"); let filename = std::env::temp_dir().join("remotes.tmp.json"); if filename.exists() { std::fs::remove_file(&filename)?; } assert!(!filename.exists(), "{} exists!", filename.display()); let mut remotes = reel::Remotes::new(&filename); println!("remotes.clobber()"); remotes.clobber()?; assert_eq!(0, remotes.origins().len(), "remotes.origins().len()"); let home = match UserDirs::new() { Some(user_dirs) => user_dirs.home_dir().to_path_buf(), None => std::env::temp_dir(), }; let dev_root = match std::env::var("DEV_ROOT") { Ok(val) => PathBuf::from(val), Err(_) => home, }; let work = dev_root.join("work"); println!("remotes.import({:?})", work); remotes.import(&work)?; println!( "after import, remotes.origins().len = {}", remotes.origins().len() ); for origin in remotes.origins() { println!("{}", origin); } Ok(()) }