67 lines
2.0 KiB
Rust
67 lines
2.0 KiB
Rust
//! Program arguments
|
|
|
|
use std::{
|
|
os::{linux::net::SocketAddrExt, unix::net::SocketAddr},
|
|
path::PathBuf,
|
|
};
|
|
|
|
use clap::Parser;
|
|
|
|
/// OpenID Connect server with unix backend
|
|
#[derive(Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
#[command(styles = get_clap_styles())]
|
|
pub struct Args {
|
|
/// Config file path to parse
|
|
#[arg(short, default_value = "/etc/authy-oidc.toml")]
|
|
pub conf: PathBuf,
|
|
|
|
/// Pamsock abstract name to connect to
|
|
#[cfg(feature = "pamsock")]
|
|
#[arg(long, default_value = "pam")]
|
|
#[arg(value_parser = parse_as_abstract_name)]
|
|
pub pamsock_abstract_name: std::os::unix::net::SocketAddr,
|
|
}
|
|
|
|
fn parse_as_abstract_name(name: &str) -> std::io::Result<SocketAddr> {
|
|
SocketAddr::from_abstract_name(name.as_bytes())
|
|
}
|
|
|
|
const fn get_clap_styles() -> clap::builder::Styles {
|
|
clap::builder::Styles::styled()
|
|
.usage(
|
|
anstyle::Style::new()
|
|
.bold()
|
|
.underline()
|
|
.fg_color(Some(anstyle::Color::Ansi256(anstyle::Ansi256Color(208)))),
|
|
)
|
|
.header(
|
|
anstyle::Style::new()
|
|
.bold()
|
|
.underline()
|
|
.fg_color(Some(anstyle::Color::Ansi256(anstyle::Ansi256Color(208)))),
|
|
)
|
|
.literal(
|
|
anstyle::Style::new().fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Yellow))),
|
|
)
|
|
.invalid(
|
|
anstyle::Style::new()
|
|
.bold()
|
|
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red))),
|
|
)
|
|
.error(
|
|
anstyle::Style::new()
|
|
.bold()
|
|
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red))),
|
|
)
|
|
.valid(
|
|
anstyle::Style::new()
|
|
.bold()
|
|
.underline()
|
|
.fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Yellow))),
|
|
)
|
|
.placeholder(
|
|
anstyle::Style::new().fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Blue))),
|
|
)
|
|
}
|