Add command module
This commit is contained in:
parent
bdd1652595
commit
d0a14d7763
31
src/command.rs
Normal file
31
src/command.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
use crate::logger::Logger;
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
|
use std::io;
|
||||||
|
use std::process::{Command, ExitStatus};
|
||||||
|
|
||||||
|
pub trait LogRunnable {
|
||||||
|
fn run(&mut self, logger: &Logger) -> Result<(), ExecutionError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LogRunnable for Command {
|
||||||
|
//TODO use specific execution error as error type
|
||||||
|
fn run(&mut self, logger: &Logger) -> Result<(), ExecutionError> {
|
||||||
|
todo!("depending on log level, pipe output and only print with logger on error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO show command in specific execution error
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ExecutionError {
|
||||||
|
StartError(io::Error),
|
||||||
|
BadExitStatus(ExitStatus),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for ExecutionError {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
ExecutionError::StartError(e) => write!(f, "failed to start command: {}", e),
|
||||||
|
ExecutionError::BadExitStatus(status) => write!(f, "command failed with exit status: {}", status),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ mod file;
|
|||||||
mod logger;
|
mod logger;
|
||||||
mod os_string_builder;
|
mod os_string_builder;
|
||||||
mod server;
|
mod server;
|
||||||
|
mod command;
|
||||||
|
|
||||||
use crate::action::{Action, FileAction, ServerActions};
|
use crate::action::{Action, FileAction, ServerActions};
|
||||||
use crate::file::{FileMatcher, FileNameInfo};
|
use crate::file::{FileMatcher, FileNameInfo};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user