You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

59 lines
1.3 KiB

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<String>,
}
#[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<u16>,
}
#[derive(ClapArgs, Debug, Clone)]
pub struct DecodeArgs {
#[arg(long, help = defaults::HELP_ENC_SYSTEM)]
pub system: Option<String>,
#[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,
}