diff --git a/clashtui/backend/src/consts.rs b/clashtui/backend/src/consts.rs index 6a3b639..2dd84f2 100644 --- a/clashtui/backend/src/consts.rs +++ b/clashtui/backend/src/consts.rs @@ -4,7 +4,6 @@ log-level: info external-controller: 127.0.0.1:9090"#; pub(crate) const BASIC_FILE: &str = "basic_clash_config.yaml"; pub(crate) const HOST: &str = "127.0.0.1"; -pub(crate) const PROXY_ENVAR: &str = "CLASHTUI_WITH_PROXY"; pub mod const_err { pub const ERR_PATH_UTF_8: &str = "path is not utf-8 form"; } diff --git a/clashtui/src/commands.rs b/clashtui/src/commands.rs index e19fa31..5e1cfd2 100644 --- a/clashtui/src/commands.rs +++ b/clashtui/src/commands.rs @@ -69,6 +69,12 @@ struct ProfileUpdate { /// the profile name #[arg(short, long)] name: Option, + /// convert proxy-provider to proxies + #[arg(long)] + no_proxy_provider: bool, + /// update profile with proxy + #[arg(long)] + with_proxy:bool } /// select profile #[derive(clap::Args)] @@ -125,7 +131,12 @@ pub fn handle_cli( let PackedArgCommand(command) = command; match command { ArgCommand::Profile(Profile { command }) => match command { - ProfileCommand::Update(ProfileUpdate { all, name }) => { + ProfileCommand::Update(ProfileUpdate { + all, + name, + no_proxy_provider, + with_proxy, + }) => { if all { backend .get_profile_names() @@ -134,7 +145,7 @@ pub fn handle_cli( .inspect(|s| println!("\nProfile: {s}")) .filter_map(|v| { backend - .update_profile(&v, false,None) + .update_profile(&v, false, Some(with_proxy)) .map_err(|e| println!("- Error! {e}")) .ok() }) @@ -143,8 +154,14 @@ pub fn handle_cli( if let Err(e) = backend.select_profile(&backend.cfg.current_profile.borrow()) { eprintln!("Select Profile: {e}") }; + if no_proxy_provider { + if let Err(e) = backend.trim_proxy_providers() { + eprint!("Convert proxy providers: {e}") + } + } Ok("Done".to_string()) } else if let Some(_name) = name { + println!("Update Profile:{_name}"); todo!() } else { Err(std::io::Error::new(