use crate::mount::{mount_dataset, MountOptions};
use crate::unmount::{unmount_dataset, UnmountOptions};
use anyhow::Result;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Mount {
#[clap(short, long)]
source: PathBuf,
#[clap(short, long)]
destination: PathBuf,
#[clap(short, long, default_value = "4")]
parallel: usize,
#[clap(long)]
mmap: bool,
#[clap(short, long)]
compress: bool,
#[clap(short, long, default_value = "90")]
threshold: u8,
},
Unmount {
#[clap(short, long)]
target: PathBuf,
#[clap(short, long)]
force: bool,
},
}
pub fn run() -> Result<()> {
let cli = Cli::parse();
match &cli.command {
Commands::Mount {
source,
destination,
parallel,
mmap,
compress,
threshold,
} => {
let options = MountOptions {
source: source.clone(),
destination: destination.clone(),
parallel: *parallel,
use_mmap: *mmap,
compress: *compress,
memory_threshold: *threshold,
};
mount_dataset(&options)?;
println!("Dataset mounted successfully.");
}
Commands::Unmount { target, force } => {
let options = UnmountOptions {
target: target.clone(),
force: *force,
};
unmount_dataset(&options)?;
println!("Dataset unmounted successfully.");
}
}
Ok(())
}