use std::path::PathBuf; use clap::{ArgAction, Args, Parser, Subcommand}; use crate::web::TextureKind; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct Cli { #[command(subcommand)] pub command: Command, } #[derive(Subcommand, Debug)] pub enum Command { /// Build the library and optionally run the webserver. Serve(ServeArgs), /// Slurp a world directory. SlurpWorld(SlurpWorldArgs), /// Slurp an Infinity Item Editor realm. SlurpRealm(SlurpRealmArgs), } #[derive(Debug, Clone, Copy, clap::ValueEnum)] #[clap(rename_all = "snake_case")] pub enum MinecraftVersion { V1_12, } #[derive(Args, Debug)] pub struct SlurpRealmArgs { #[arg(short = 'v', long = "version", default_value = "v1_12")] pub version: MinecraftVersion, /// The path to the `realm.nbt` file created by Infinity Item Editor. #[arg(short = 'r', long = "realm", default_value = "realm.nbt")] pub realm_path: PathBuf, /// Path to the book container to create or update. #[arg( short = 'c', long = "container", default_value = "container.json.gz" )] pub container_path: PathBuf, } #[derive(Args, Debug)] pub struct SlurpWorldArgs { #[arg(short = 'v', long = "version", default_value = "v1_12")] pub version: MinecraftVersion, /// Path to the world directory. #[arg(short = 'w', long = "world")] pub world_path: PathBuf, /// Number of worker threads used for parallel file slurping. /// Defaults to the number of logical CPUs. #[arg(short = 'j', long = "workers")] pub workers: Option, /// Path to the book container to create or update. #[arg( short = 'c', long = "container", default_value = "container.json.gz" )] pub container_path: PathBuf, } #[derive(Args, Debug)] pub struct ServeArgs { /// Whether to warn about empty/whitespace books being skipped during indexing. #[arg(short = 'e', long, default_value_t = true, action = ArgAction::Set)] pub warn_empty: bool, /// Whether to skip indexing books whose plain-text content is empty/whitespace. #[arg(short = 'f', long, default_value_t = true, action = ArgAction::Set)] pub filter_empty_books: bool, /// The score threshold for fuzzy finding book content. #[arg(short = 'C', long, default_value_t = 0.78)] pub content_threshold: f64, /// The score threshold for fuzzy finding book titles. #[arg(short = 'T', long, default_value_t = 0.80)] pub title_threshold: f64, /// The score threshold for fuzzy finding book authors. #[arg(short = 'A', long, default_value_t = 0.82)] pub author_threshold: f64, /// Path to the book container to load. #[arg( short = 'c', long = "container", default_value = "container.json.gz" )] pub container_path: PathBuf, #[arg(short = 's', long = "dont-start-webserver", action = ArgAction::SetFalse)] pub start_webserver: bool, /// Address to bind the webserver to. #[arg( short = 'a', long = "host-address", default_value = "127.0.0.1:3000" )] pub webserver_host_address: String, /// Minecraft block/item texture variants to serve by default. #[arg(short, long, value_enum, default_value = "modern")] pub ui_textures: TextureKind, }