1use clap::Parser;
2
3#[derive(Parser, Debug)]
5#[command(
6 author,
7 version,
8 about = "This tool can be used to obtain IP addresses by country or by AS number."
9)]
10pub struct Cli {
11 #[arg(
12 short = 'c',
13 long = "country",
14 required_unless_present_any = ["as_numbers", "overlap"],
15 required = false,
16 num_args = 1..,
17 help = "Specify the country codes.\nExample: jp br us"
18 )]
19 pub country_codes: Option<Vec<String>>,
20
21 #[arg(
22 short = 'a',
23 long = "as-number",
24 required_unless_present_any = ["country_codes", "overlap"],
25 required = false,
26 value_parser = clap::value_parser!(u32),
27 num_args = 1..,
28 help = "Specify AS numbers.\nExample: 0000 1234"
29 )]
30 pub as_numbers: Option<Vec<u32>>,
31
32 #[arg(
33 short = 'm',
34 long = "mode",
35 default_value = "overwrite",
36 required = false,
37 hide_default_value = true,
38 help = "Select file output mode: 'append' or 'overwrite'.\ndefault: overwrite"
39 )]
40 pub mode: String,
41
42 #[arg(
43 short = 'o',
44 long = "overlap",
45 help = "Write down the IP addresses of the overlapping country and AS numbers in a file of your choice.\nBoth the -c and -a arguments must be specified.",
46 required = false,
47 default_value = "false",
48 requires("country_codes"),
49 requires("as_numbers")
50 )]
51 pub overlap: bool,
52
53 #[arg(
54 short = 'f',
55 long = "format",
56 default_value = "txt",
57 required = false,
58 hide_default_value = true,
59 help = "Select output format: 'txt' or 'nft'.\ndefault: txt"
60 )]
61 pub output_format: String,
62}