adnix-rs/src/cli_opts.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.0 KiB
Rust
Raw Permalink Normal View History

2022-06-17 12:56:12 +05:30
use clap::{Parser, ValueEnum};
#[derive(Debug, Parser)]
2022-09-29 11:37:09 +05:30
#[command(
author,
version,
about = "CLI tool to convert ad blocking hosts files into DNSMasq or Unbound configuration files"
)]
pub(crate) struct Opts {
/// Output file
2022-09-29 11:37:09 +05:30
#[arg(long, short)]
pub(crate) output: Option<String>,
/// Formatter
2022-09-29 11:37:09 +05:30
#[arg(value_enum, long, short, default_value_t = FormatterOpt::Dnsmasq)]
pub(crate) formatter: FormatterOpt,
/// IPv4 address
2022-09-29 11:37:09 +05:30
#[arg(long = "address", default_value = "127.0.0.1")]
pub(crate) ipv4_address: String,
/// IPv6 address
2022-09-29 11:37:09 +05:30
#[arg(long = "v6address", default_value = "::1")]
pub(crate) ipv6_address: String,
/// File to read "name|source url" mappings from
2022-09-29 11:37:09 +05:30
#[arg(long, short)]
pub(crate) sources_file: String,
}
2022-06-17 12:56:12 +05:30
#[derive(ValueEnum, Clone, Debug)]
pub(crate) enum FormatterOpt {
Dnsmasq,
DnsmasqServer,
Unbound,
}
2022-08-11 15:16:24 +05:30
#[cfg(test)]
mod test {
use super::Opts;
#[test]
fn cli_assert() {
2023-08-25 03:39:55 +05:30
<Opts as clap::CommandFactory>::command().debug_assert();
2022-08-11 15:16:24 +05:30
}
}