Skip to content

Commit

Permalink
cml impl --no-proxy-provider --with-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackhr-arch committed Jun 28, 2024
1 parent 8dca4c8 commit 6ab4834
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion clashtui/backend/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
21 changes: 19 additions & 2 deletions clashtui/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ struct ProfileUpdate {
/// the profile name
#[arg(short, long)]
name: Option<String>,
/// 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)]
Expand Down Expand Up @@ -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()
Expand All @@ -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()
})
Expand All @@ -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(
Expand Down

0 comments on commit 6ab4834

Please sign in to comment.