Skip to content

Commit

Permalink
Set RUST_LOG for dialog command
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 24, 2024
1 parent 3c93189 commit c5fbfcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use iced::{
alignment,
widget::{button, text, Column, Container, Row},
Expand All @@ -7,7 +9,7 @@ use iced::{
use crate::{
gui::{icon::Icon, style},
lang::TRANSLATOR,
prelude::{run_command, Privacy},
prelude::{run_command_env, Privacy},
resource::config,
};

Expand All @@ -28,11 +30,12 @@ pub fn confirm(message: &str) -> bool {

pub fn show(kind: Kind, message: &str) -> bool {
let exe = std::env::current_exe().unwrap().to_string_lossy().to_string();
match run_command(
match run_command_env(
&exe,
&["dialog", "--kind", kind.slug(), "--message", message],
&[0],
Privacy::Public,
HashMap::from_iter([("RUST_LOG".to_string(), "debug".to_string())]),
) {
Ok(info) => info.stdout.contains(POSITIVE_CHOICE),
Err(e) => {
Expand Down
12 changes: 12 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
collections::HashMap,
num::NonZeroUsize,
path::PathBuf,
sync::{atomic::AtomicBool, Arc, LazyLock, Mutex},
Expand Down Expand Up @@ -220,11 +221,22 @@ pub fn run_command(
args: &[&str],
success: &[i32],
privacy: Privacy,
) -> Result<CommandOutput, CommandError> {
run_command_env(executable, args, success, privacy, HashMap::new())
}

pub fn run_command_env(
executable: &str,
args: &[&str],
success: &[i32],
privacy: Privacy,
env: HashMap<String, String>,
) -> Result<CommandOutput, CommandError> {
let mut command = std::process::Command::new(executable);
command.stdout(std::process::Stdio::piped());
command.stderr(std::process::Stdio::piped());
command.args(args);
command.envs(env);

#[cfg(target_os = "windows")]
{
Expand Down

0 comments on commit c5fbfcf

Please sign in to comment.