diff options
| author | Fuwn <[email protected]> | 2021-06-02 04:05:45 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-06-02 04:05:45 +0000 |
| commit | e4a3d642a64b0c15d127f040419d805e2f0dff34 (patch) | |
| tree | e00cbfea71068a113fe8aaca672d8cd4fa133b15 /src/cli.rs | |
| parent | refactor(clippy): strictor clippy constraints (diff) | |
| download | nitrous-e4a3d642a64b0c15d127f040419d805e2f0dff34.tar.xz nitrous-e4a3d642a64b0c15d127f040419d805e2f0dff34.zip | |
feat(check): proxy support
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 55 |
1 files changed, 53 insertions, 2 deletions
@@ -1,6 +1,8 @@ // Copyleft (ɔ) 2021-2021 Fuwn // SPDX-License-Identifier: GPL-3.0-only +use std::str::FromStr; + use structopt::{ clap, clap::{App, Arg, SubCommand}, @@ -8,6 +10,26 @@ use structopt::{ use crate::nitrous::Nitrous; +pub enum ProxyType { + Http, + Socks4, + Socks5, + Tor, +} +impl FromStr for ProxyType { + type Err = &'static str; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + match s { + "http" => Ok(Self::Http), + "socks4" => Ok(Self::Socks4), + "socks5" => Ok(Self::Socks5), + "tor" => Ok(Self::Tor), + _ => Err("no match"), + } + } +} + pub struct Cli; impl Cli { pub async fn execute() { @@ -43,6 +65,19 @@ impl Cli { } }, debug, + ProxyType::from_str( + matches + .subcommand_matches("check") + .unwrap() + .value_of("proxy_type") + .unwrap(), + ) + .unwrap(), + matches + .subcommand_matches("check") + .unwrap() + .value_of("proxy_list") + .unwrap_or("null"), ) .await; } @@ -76,8 +111,24 @@ impl Cli { Arg::with_name("file") .required(false) .takes_value(true) - .index(1), - ), + .long("file") + .short("f"), + ) + .args(&[ + Arg::with_name("proxy_type") + .required(true) + .takes_value(true) + .index(1) + .possible_values(&["http", "socks4", "socks5", "tor"]), + Arg::with_name("proxy_list") + .required_ifs(&[ + ("proxy_type", "http"), + ("proxy_type", "socks4"), + ("proxy_type", "socks5"), + ]) + .takes_value(true) + .index(2), + ]), ]) .arg( Arg::with_name("debug") |