1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use super::config_url::ConfigUrl;
#[derive(Debug, Subcommand)]
pub enum Command {
CheckConfig {
#[arg(
short,
long,
value_name = "CONFIG",
default_value = "https://raw.githubusercontent.com/ragibkl/adblock-dns-server/master/data/configuration.yaml"
)]
config_url: ConfigUrl,
#[arg(short, long, value_name = "CONFIG", default_value = "./blacklist.zone")]
output: PathBuf,
#[arg(short, long, value_name = "FORMAT", default_value = "zone")]
format: String,
},
Compile {
#[arg(
short,
long,
value_name = "CONFIG",
default_value = "https://raw.githubusercontent.com/ragibkl/adblock-dns-server/master/data/configuration.yaml"
)]
config_url: ConfigUrl,
#[arg(short, long, value_name = "CONFIG", default_value = "./blacklist.zone")]
output: PathBuf,
#[arg(short, long, value_name = "FORMAT", default_value = "zone")]
format: String,
},
}
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
impl Cli {
pub fn from_args() -> Self {
Self::parse()
}
}