use anyhow::Result; use clap::{Parser, ValueEnum}; use link2epub::{convert, Format, Options}; const VERSION: &str = "v0_20260914"; #[derive(Debug, Parser)] #[command(version, about)] struct Cli { /// url of the article to download url: String, /// output type: epub or mobi #[arg(short = 't', value_enum, default_value_t = OutputFormat::Epub)] output_type: OutputFormat, } #[derive(Clone, Copy, Debug, ValueEnum)] enum OutputFormat { Epub, Mobi, } impl From for Format { fn from(value: OutputFormat) -> Self { match value { OutputFormat::Epub => Self::Epub, OutputFormat::Mobi => Self::Mobi, } } } fn main() -> Result<()> { println!("link2epub (rs) version {}", VERSION); let cli = Cli::parse(); let output = convert(Options { url: cli.url, format: cli.output_type.into(), })?; println!("Created {}", output.display()); Ok(()) }