mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
chore: preserve capitalization in non-error output
This commit is contained in:
parent
0a4437f5b5
commit
fb1d1956d0
2 changed files with 8 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use pay_respects_utils::evals::split_command;
|
use pay_respects_utils::evals::split_command;
|
||||||
use pay_respects_utils::files::get_path_files;
|
use pay_respects_utils::files::get_path_files;
|
||||||
use std::process::exit;
|
use std::process::{exit, Stdio};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
|
@ -248,12 +248,12 @@ pub fn get_error(shell: &str, command: &str) -> String {
|
||||||
std::env::remove_var("_PR_ERROR_MSG");
|
std::env::remove_var("_PR_ERROR_MSG");
|
||||||
error_msg
|
error_msg
|
||||||
} else {
|
} else {
|
||||||
command_output_threaded(shell, command)
|
error_output_threaded(shell, command)
|
||||||
};
|
};
|
||||||
error.split_whitespace().collect::<Vec<&str>>().join(" ")
|
error.split_whitespace().collect::<Vec<&str>>().join(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_output_threaded(shell: &str, command: &str) -> String {
|
pub fn error_output_threaded(shell: &str, command: &str) -> String {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
let _shell = shell.to_owned();
|
let _shell = shell.to_owned();
|
||||||
|
|
@ -289,12 +289,13 @@ pub fn command_output(shell: &str, command: &str) -> String {
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command)
|
.arg(command)
|
||||||
.env("LC_ALL", "C")
|
.env("LC_ALL", "C")
|
||||||
|
.stderr(Stdio::inherit())
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
match output.stdout.is_empty() {
|
match output.stdout.is_empty() {
|
||||||
false => String::from_utf8_lossy(&output.stdout).to_lowercase(),
|
false => String::from_utf8_lossy(&output.stdout).to_string(),
|
||||||
true => String::from_utf8_lossy(&output.stderr).to_lowercase(),
|
true => String::from_utf8_lossy(&output.stderr).to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,14 +313,10 @@ pub fn module_output(data: &Data, module: &str) -> Option<Vec<String>> {
|
||||||
.env("_PR_LAST_COMMAND", last_command)
|
.env("_PR_LAST_COMMAND", last_command)
|
||||||
.env("_PR_ERROR_MSG", error_msg)
|
.env("_PR_ERROR_MSG", error_msg)
|
||||||
.env("_PR_EXECUTABLES", executables)
|
.env("_PR_EXECUTABLES", executables)
|
||||||
.stderr(std::process::Stdio::inherit())
|
.stderr(Stdio::inherit())
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute process");
|
.expect("failed to execute process");
|
||||||
|
|
||||||
if !output.stderr.is_empty() {
|
|
||||||
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
}
|
|
||||||
|
|
||||||
if output.stdout.is_empty() {
|
if output.stdout.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ pub fn install_package(data: &mut Data, package_manager: &str, package: &str) ->
|
||||||
"nix" => format!("nix profile install nixpkgs#{}", package),
|
"nix" => format!("nix profile install nixpkgs#{}", package),
|
||||||
"pacman" => format!("pacman -S {}", package),
|
"pacman" => format!("pacman -S {}", package),
|
||||||
_ => match package_manager.ends_with("command-not-found") {
|
_ => match package_manager.ends_with("command-not-found") {
|
||||||
true => match package.starts_with("command ") {
|
true => match package.starts_with("Command ") {
|
||||||
false => package.to_string(),
|
false => package.to_string(),
|
||||||
true => {
|
true => {
|
||||||
let split = package.split_whitespace().collect::<Vec<&str>>();
|
let split = package.split_whitespace().collect::<Vec<&str>>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue