diff --git a/.gitignore b/.gitignore index 143b1ca..6ddc762 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /target/ **/*.rs.bk Cargo.lock +fonky.out diff --git a/fonky.txt b/fonky.txt new file mode 100644 index 0000000..811b327 --- /dev/null +++ b/fonky.txt @@ -0,0 +1 @@ +This is some fonky stuff! diff --git a/src/platform/fonky.rs b/src/platform/fonky.rs new file mode 100644 index 0000000..68d9760 --- /dev/null +++ b/src/platform/fonky.rs @@ -0,0 +1,41 @@ +use super::Platform; + +use std::fs::metadata; +use std::process::Command; + +pub struct Fonky {} + +impl Platform for Fonky { + fn probe(&self) -> bool { + metadata("./fonky.txt") + .map(|data| data.is_file()) + .unwrap_or(false) + } + + fn build(&self) -> bool { + println!("building a Fonky project"); + + let output = Command::new("cp").arg("fonky.txt").arg("fonky.out").output().expect( + "Fonky build failed", + ); + + println!("{}", String::from_utf8_lossy(&output.stdout)); + eprintln!("{}", String::from_utf8_lossy(&output.stderr)); + + output.status.success() + + } + + fn run(&self) -> bool { + println!("running a Fonky project"); + + let output = Command::new("cat").arg("fonky.out").output().expect( + "Fonky run failed", + ); + + println!("{}", String::from_utf8_lossy(&output.stdout)); + println!("{}", String::from_utf8_lossy(&output.stderr)); + + output.status.success() + } +} \ No newline at end of file diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 555fa4a..6bedf36 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -1,6 +1,9 @@ mod rust; use self::rust::Rust; +mod fonky; +use self::fonky::Fonky; + pub trait Platform { fn probe(&self) -> bool; @@ -11,7 +14,10 @@ pub trait Platform { pub fn probe() -> Option> { let rust = Rust {}; - if rust.probe() { + let fonky = Fonky {}; + if fonky.probe() { + Some(Box::new(fonky)) + } else if rust.probe() { Some(Box::new(rust)) } else { None