73 lines
1.7 KiB
Rust
73 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>,
|
|
#[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,
|
|
#[arg(
|
|
long,
|
|
short,
|
|
help = "a seperator character to seperate the url from the name. defaults to ,",
|
|
requires = "url",
|
|
requires = "name"
|
|
)]
|
|
seperator: Option<char>,
|
|
#[arg(
|
|
long,
|
|
short,
|
|
conflicts_with = "url",
|
|
conflicts_with = "name",
|
|
conflicts_with = "seperator",
|
|
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,
|
|
}
|