Remove minor code duplication
This commit is contained in:
parent
6b0b648d67
commit
ca7be76937
@ -1,9 +1,9 @@
|
|||||||
use crate::log;
|
use crate::log;
|
||||||
use crate::logger::{LogLevel, Logger};
|
use crate::logger::{LogLevel, Logger};
|
||||||
|
use crate::shell_interface::command_to_string;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt::{Debug, Display, Formatter};
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::iter::once;
|
|
||||||
use std::process::{Command, ExitStatus, Output};
|
use std::process::{Command, ExitStatus, Output};
|
||||||
|
|
||||||
pub trait LogRunnable {
|
pub trait LogRunnable {
|
||||||
@ -89,20 +89,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_to_string(command: &Command) -> String {
|
|
||||||
once(command.get_program().to_string_lossy().to_string())
|
|
||||||
.chain(command.get_args().map(|arg| {
|
|
||||||
let arg_str = arg.to_string_lossy();
|
|
||||||
if arg_str.contains(' ') {
|
|
||||||
format!("\"{arg_str}\"")
|
|
||||||
} else {
|
|
||||||
arg_str.to_string()
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(" ")
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<E> Error for CommandSpecificError<'_, E> where E: Debug + Display {}
|
impl<E> Error for CommandSpecificError<'_, E> where E: Debug + Display {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@ -79,7 +79,8 @@ impl Display for ShellCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_to_string(command: &Command) -> String {
|
//TODO remove crate visibility once it isn't needed anymore
|
||||||
|
pub(crate) fn command_to_string(command: &Command) -> String {
|
||||||
once(command.get_program().to_string_lossy().to_string())
|
once(command.get_program().to_string_lossy().to_string())
|
||||||
.chain(command.get_args().map(|arg| {
|
.chain(command.get_args().map(|arg| {
|
||||||
let arg_str = arg.to_string_lossy();
|
let arg_str = arg.to_string_lossy();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user