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", long, short)] pub(crate) path: Option, #[arg( long, short, help = "a seperator string to seperate the url from the name. defaults to : with a space after that." )] pub(crate) seperator: Option, #[command(subcommand)] pub(crate) command: Commands, } #[derive(Subcommand, Debug)] pub(crate) enum Commands { #[command(about = "print the current webring sites and their names")] Print { #[arg(help = "url you want to filter to")] filter: Option, #[command(flatten)] group: PrintGroup, #[arg( long, short, conflicts_with = "url", conflicts_with = "name", help = "print the data out as a json string" )] json: bool, }, #[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, }, #[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, help = "print the url only")] pub(crate) url: bool, #[arg(long, short, action = clap::ArgAction::SetTrue, help = "print the name only")] pub(crate) name: bool, }