use clap::{ArgAction, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(
author,
version,
about = "Mount Git history as a read-only filesystem",
after_help = "Examples:\n timefs mount ~/code/git /mnt/git -f\n timefs mount ~/code/linux /mnt/linux --ref-snapshot --cache-size 512\n timefs unmount /mnt/git",
propagate_version = true
)]
pub struct Cli {
#[arg(short, long, global = true, action = ArgAction::Count)]
pub verbose: u8,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Mount(MountArgs),
Unmount(UnmountArgs),
}
#[derive(Debug, Clone, Parser)]
#[command(
after_help = "Examples:\n timefs mount ~/code/git /mnt/git -f\n timefs mount ~/code/linux /mnt/linux --allow-other --cache-size 512\n timefs mount ~/code/repo /mnt/repo --ref-snapshot --submodules recurse"
)]
pub struct MountArgs {
pub repo: PathBuf,
pub mountpoint: PathBuf,
#[arg(short = 'f', long)]
pub foreground: bool,
#[arg(long)]
pub allow_other: bool,
#[arg(long, value_enum, default_value_t = SubmodulesMode::Placeholder)]
pub submodules: SubmodulesMode,
#[arg(long)]
pub lfs: bool,
#[arg(long)]
pub ref_snapshot: bool,
#[arg(long = "cache-size", default_value_t = 256)]
pub cache_size_mb: usize,
#[arg(long)]
pub uid: Option<u32>,
#[arg(long)]
pub gid: Option<u32>,
}
#[derive(Debug, Clone, Parser)]
#[command(after_help = "Example:\n timefs unmount /mnt/git")]
pub struct UnmountArgs {
pub mountpoint: PathBuf,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
pub enum SubmodulesMode {
Placeholder,
Recurse,
}