Skip to content

Commit

Permalink
add env template
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackhr-arch committed Sep 4, 2024
1 parent e6bad35 commit 90bdd53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/bin/clashtui/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct ProfileUpdate {
name: Option<String>,
/// update profile with proxy
#[arg(long)]
with_proxy: bool,
with_proxy: Option<bool>,
}
/// select profile
#[derive(clap::Args)]
Expand Down
20 changes: 5 additions & 15 deletions src/bin/clashtui/commands/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use crate::utils::BackEnd;
use super::*;

pub fn handle_cli(command: PackedArgs, backend: BackEnd) -> anyhow::Result<String> {
// let var: Option<bool> = std::env::var("CLASHTUI_")
// .ok()
// .and_then(|s| s.parse().ok());
let PackedArgs(command) = command;
match command {
ArgCommand::Profile(Profile { command }) => match command {
Expand All @@ -20,7 +23,7 @@ pub fn handle_cli(command: PackedArgs, backend: BackEnd) -> anyhow::Result<Strin
.inspect(|s| println!("Profile: {}", s.name))
.filter_map(|v| {
backend
.update_profile(&v, Some(with_proxy))
.update_profile(&v, with_proxy)
.map_err(|e| println!("- Error! {e}"))
.ok()
})
Expand All @@ -36,7 +39,7 @@ pub fn handle_cli(command: PackedArgs, backend: BackEnd) -> anyhow::Result<Strin
} else {
anyhow::bail!("Not found in database!");
};
match backend.update_profile(&pf, Some(with_proxy)) {
match backend.update_profile(&pf, with_proxy) {
Ok(v) => {
v.into_iter().for_each(|s| println!("- {s}"));
}
Expand Down Expand Up @@ -73,19 +76,6 @@ pub fn handle_cli(command: PackedArgs, backend: BackEnd) -> anyhow::Result<Strin
}
ServiceCommand::Stop => Ok(backend.clash_srv_ctl(ServiceOp::StopClashService)?),
},
#[cfg(any(target_os = "linux", target_os = "macos"))]
ArgCommand::Mode(Mode { command }) => match command {
ModeCommand::Rule => Ok(backend
.update_state(None, Some(cMode::Rule.into()))?
.to_string()),
ModeCommand::Direct => Ok(backend
.update_state(None, Some(cMode::Direct.into()))?
.to_string()),
ModeCommand::Global => Ok(backend
.update_state(None, Some(cMode::Global.into()))?
.to_string()),
},
#[cfg(target_os = "windows")]
ArgCommand::Mode(Mode { command }) => match command {
ModeCommand::Rule => Ok(backend
.update_state(None, Some(cMode::Rule.into()))?
Expand Down

0 comments on commit 90bdd53

Please sign in to comment.