diff options
Diffstat (limited to 'src/project.rs')
-rw-r--r-- | src/project.rs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/project.rs b/src/project.rs index 5f1edc5..e6faf66 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,7 @@ use std::{ + io::Write, path::PathBuf, + process::{Command, Stdio}, time::{Duration, SystemTime}, }; @@ -13,6 +15,20 @@ mod path; pub type ProjectItem = Box<dyn Project<Error = Error>>; +pub trait Project: Timestamp { + fn to_path_buf(&self) -> &PathBuf; +} + +impl<T> Project for T +where + T: Timestamp, + T: AsRef<PathBuf>, +{ + fn to_path_buf(&self) -> &PathBuf { + self.as_ref() + } +} + pub trait Timestamp { type Error; @@ -34,16 +50,26 @@ where } } -pub trait Project: Timestamp { - fn to_path_buf(&self) -> &PathBuf; +pub trait Preview { + type Error; + + fn preview(&self) -> Result<(), Self::Error>; } -impl<T> Project for T +impl<T> Preview for T where - T: Timestamp, T: AsRef<PathBuf>, { - fn to_path_buf(&self) -> &PathBuf { - self.as_ref() + type Error = std::io::Error; + + fn preview(&self) -> Result<(), Self::Error> { + let output = Command::new("ls") + .arg("-l") + .arg("-a") + .arg(self.to_path_buf()) + .stdout(Stdio::piped()) + .output()?; + + std::io::stdout().write_all(&output.stdout) } } |