relay/src/args.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

use clap::Parser;
#[derive(Debug, Parser)]
#[structopt(name = "relay", about = "An activitypub relay")]
2021-02-10 04:17:20 +00:00
pub(crate) struct Args {
#[arg(short, help = "A list of domains that should be blocked")]
blocks: Vec<String>,
#[arg(short, help = "A list of domains that should be allowed")]
2021-02-10 04:05:06 +00:00
allowed: Vec<String>,
#[arg(short, long, help = "Undo allowing or blocking domains")]
undo: bool,
#[arg(short, long, help = "List allowed and blocked domains")]
list: bool,
2022-11-19 23:45:01 +00:00
#[arg(short, long, help = "Get statistics from the server")]
stats: bool,
}
impl Args {
2022-11-17 20:13:41 +00:00
pub(crate) fn any(&self) -> bool {
2022-11-19 23:45:01 +00:00
!self.blocks.is_empty() || !self.allowed.is_empty() || self.list || self.stats
2022-11-17 20:13:41 +00:00
}
2021-02-10 04:17:20 +00:00
pub(crate) fn new() -> Self {
Self::parse()
}
2021-02-10 04:17:20 +00:00
pub(crate) fn blocks(&self) -> &[String] {
&self.blocks
}
2021-02-10 04:17:20 +00:00
pub(crate) fn allowed(&self) -> &[String] {
2021-02-10 04:05:06 +00:00
&self.allowed
}
2021-02-10 04:17:20 +00:00
pub(crate) fn undo(&self) -> bool {
self.undo
}
pub(crate) fn list(&self) -> bool {
self.list
}
2022-11-19 23:45:01 +00:00
pub(crate) fn stats(&self) -> bool {
self.stats
}
}