use clap::{Parser, Subcommand, ValueEnum};
#[derive(Clone, ValueEnum)]
pub enum Channel {
Stable,
Beta,
Nightly,
}
impl std::fmt::Display for Channel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Channel::Stable => write!(f, "stable"),
Channel::Beta => write!(f, "beta"),
Channel::Nightly => write!(f, "nightly"),
}
}
}
#[derive(Parser)]
#[command(name = "rs-histver")]
#[command(about = "Query Rust historical release versions")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Sync {
#[arg(short, long, value_enum, default_value = "stable")]
channel: Channel,
#[arg(long)]
full: bool,
#[arg(short, long, default_value = "30")]
days: u32,
},
List {
#[arg(short, long, default_value = "20")]
limit: usize,
#[arg(short, long, value_enum)]
channel: Option<Channel>,
},
Search {
keyword: String,
#[arg(short, long, value_enum)]
channel: Option<Channel>,
},
Info {
#[arg(short, long, value_enum)]
channel: Option<Channel>,
},
}