2022-06-17 12:56:12 +05:30
|
|
|
use clap::{Parser, ValueEnum};
|
2021-10-04 14:57:59 +05:30
|
|
|
|
2021-10-18 13:45:36 +05:30
|
|
|
#[derive(Debug, Parser)]
|
2022-09-29 11:37:09 +05:30
|
|
|
#[command(
|
2021-10-04 14:57:59 +05:30
|
|
|
author,
|
|
|
|
version,
|
2021-10-18 13:45:36 +05:30
|
|
|
about = "CLI tool to convert ad blocking hosts files into DNSMasq or Unbound configuration files"
|
2021-10-04 14:57:59 +05:30
|
|
|
)]
|
|
|
|
pub(crate) struct Opts {
|
|
|
|
/// Output file
|
2022-09-29 11:37:09 +05:30
|
|
|
#[arg(long, short)]
|
2021-10-04 14:57:59 +05:30
|
|
|
pub(crate) output: Option<String>,
|
|
|
|
|
|
|
|
/// Formatter
|
2022-09-29 11:37:09 +05:30
|
|
|
#[arg(value_enum, long, short, default_value_t = FormatterOpt::Dnsmasq)]
|
2021-10-04 14:57:59 +05:30
|
|
|
pub(crate) formatter: FormatterOpt,
|
|
|
|
|
|
|
|
/// IPv4 address
|
2022-09-29 11:37:09 +05:30
|
|
|
#[arg(long = "address", default_value = "127.0.0.1")]
|
2021-10-04 14:57:59 +05:30
|
|
|
pub(crate) ipv4_address: String,
|
|
|
|
|
|
|
|
/// IPv6 address
|
2022-09-29 11:37:09 +05:30
|
|
|
#[arg(long = "v6address", default_value = "::1")]
|
2021-10-04 14:57:59 +05:30
|
|
|
pub(crate) ipv6_address: String,
|
|
|
|
|
|
|
|
/// File to read "name|source url" mappings from
|
2022-09-29 11:37:09 +05:30
|
|
|
#[arg(long, short)]
|
2021-10-04 14:57:59 +05:30
|
|
|
pub(crate) sources_file: String,
|
|
|
|
}
|
|
|
|
|
2022-06-17 12:56:12 +05:30
|
|
|
#[derive(ValueEnum, Clone, Debug)]
|
2021-10-04 14:57:59 +05:30
|
|
|
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
|
|
|
}
|
|
|
|
}
|