use std::{env, path::PathBuf};
use cvmfs::{fetcher::Fetcher, file_system::CernvmFileSystem, repository::Repository};
fn main() {
env_logger::init();
let args: Vec<String> = env::args().collect();
if args.len() < 3 {
panic!("Please specify url of the repository and the mount point");
}
let repo_url = &args[1];
let mountpoint = PathBuf::from(&args[2]);
if !mountpoint.exists() {
panic!("Mount point does not exist");
}
if !mountpoint.is_dir() {
panic!("Mount point is not a directory");
}
let repo_cache = if args.len() > 3 { args[3].clone() } else { "/tmp/cvmfs".into() };
let fetcher = Fetcher::new(repo_url, &repo_cache, true).expect("Failure creating the fetcher");
let repository = Repository::new(fetcher).expect("Failure creating the repository");
let file_system = CernvmFileSystem::new(repository).expect("Failure creating the file system");
file_system
.mount(mountpoint.to_str().expect("Invalid mount point string"))
.expect("Could not mount the file system");
}