meowy-webring/cli/src/arguments.rs

56 lines
1.3 KiB
Rust

use clap::{arg, command, Args, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub(crate) struct Arguments {
#[arg(help = "the path to the names.json file")]
pub(crate) path: String,
#[command(subcommand)]
pub(crate) command: Commands,
}
#[derive(Subcommand, Debug)]
pub(crate) enum Commands {
#[command(about = "print the current webring sites and their names")]
Print {
#[command(flatten)]
group: PrintGroup,
},
#[command(about = "add a site to the webring")]
Add {
#[arg(
long,
short,
required = true,
help = "the url of the site you want to add. example: \"example.com\"."
)]
url: String,
#[arg(
long,
short,
required = false,
help = "the personal name of the site. this is not required."
)]
name: Option<String>,
},
#[command(about = "remove a site from the webring")]
Remove {
#[arg(
long,
short,
required = true,
help = "the url of the site you want to remove."
)]
url: String,
},
}
#[derive(Args, Debug)]
#[group(required = false)]
pub struct PrintGroup {
#[arg(long, short, action = clap::ArgAction::SetTrue, conflicts_with = "name", help = "print the url only")]
pub(crate) url: bool,
#[arg(long, short, action = clap::ArgAction::SetTrue, conflicts_with = "url", help = "print the name only")]
pub(crate) name: bool,
}