Skip to content

Commit

Permalink
fix: parse cmd output
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed Jun 28, 2023
1 parent 6f343a0 commit ac31ead
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use std::str;
use std::sync::{Arc, Mutex};

use tracing::info;
use tracing::{info, error};

const APP_PORT_KEY: &str = "--app-port=";
const TOKEN_KEY: &str = "--remoting-auth-token=";
Expand Down Expand Up @@ -37,28 +37,28 @@ pub struct CommandLineOutput {
pub fn get_commandline() -> CommandLineOutput {
use std::{os::windows::process::CommandExt, process::Command};

if let Ok(output) = Command::new("powershell")
.args([
"-ExecutionPolicy",
"Bypass",
"-NoLogo",
"-NoProfile",
"-NonInteractive",
"-WindowStyle",
"Hidden",
"-Command",
LCU_COMMAND,
])
.creation_flags(0x08000000)
.output()
{
if output.status.success() {
if let Ok(utf8_output) = str::from_utf8(&output.stdout) {
if !utf8_output.is_empty() {
return match_stdout(&String::from(utf8_output));
}
match Command::new("powershell")
.args([
"-ExecutionPolicy",
"Bypass",
"-NoLogo",
"-NoProfile",
"-NonInteractive",
"-WindowStyle",
"Hidden",
"-Command",
LCU_COMMAND,
])
.creation_flags(0x08000000)
.output() {
Ok(output) => {
if output.status.success() {
let output = String::from_utf8_lossy(&output.stdout);
info!("cmd output: {:?}", &output);
return match_stdout(&String::from(output));
}
}
Err(err) => error!("cmd error: {:?}", err)
}

CommandLineOutput {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Application for ChampR {
}

fn title(&self) -> String {
String::from("ChampR - Builds, Runes, All in One. v2.0.2-b4")
String::from("ChampR - Builds, Runes, All in One. v2.0.2-b5")
}

fn update(&mut self, message: Message) -> Command<Message> {
Expand Down

0 comments on commit ac31ead

Please sign in to comment.