use crate::cli::defaults; use clap::{Args as ClapArgs, Parser, Subcommand}; use std::path::PathBuf; #[derive(Parser, Debug)] #[command(author, version, about)] pub struct CliArgs { #[command(flatten)] pub global: GlobalArgs, #[command(subcommand)] pub command: Command, } #[derive(ClapArgs, Debug)] pub struct GlobalArgs { /// Path to config file #[arg(short, long, default_value = "config.toml")] pub config: PathBuf, #[arg(long, help = defaults::HELP_LOG)] pub log_level: Option, } #[derive(Subcommand, Debug, Clone)] pub enum Command { /// Start the application server Server(ServerArgs), /// Decode a word using given system Decode(DecodeArgs), /// Import dictionary ImportDict(ImportDictArgs), } #[derive(ClapArgs, Debug, Clone)] pub struct ServerArgs { #[arg(short, long, help = defaults::HELP_PORT)] pub port: Option, } #[derive(ClapArgs, Debug, Clone)] pub struct DecodeArgs { #[arg(long, help = defaults::HELP_ENC_SYSTEM)] pub system: Option, #[arg(long, help = defaults::HELP_ENC_INPUT)] pub input: String, } #[derive(ClapArgs, Debug, Clone)] pub struct ImportDictArgs { #[arg(long, help = defaults::HELP_IMPORT_DICT_NAME)] pub name: String, #[arg(long, help = defaults::HELP_IMPORT_DICT_INPUT)] pub path: String, }