intial commit
This commit is contained in:
62
src/args.rs
Normal file
62
src/args.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
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 {
|
||||
#[arg(short, default_value = "/etc/authy-oidc.toml")]
|
||||
pub conf: PathBuf,
|
||||
|
||||
#[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))),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user