meowy-webring/crates/cli/src/arguments.rs

72 lines
1.7 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", long, short)]
pub(crate) path: Option<String>,
#[arg(
long,
short,
help = "a separator string to seperate the url from the name. defaults to : with a space after that."
)]
pub(crate) separator: Option<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 {
#[arg(help = "url you want to filter to")]
filter: Option<String>,
#[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<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, 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,
}