Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Not sure if you'll like this one but it's fonky! #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/target/
**/*.rs.bk
Cargo.lock
fonky.out
1 change: 1 addition & 0 deletions fonky.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is some fonky stuff!
41 changes: 41 additions & 0 deletions src/platform/fonky.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}
8 changes: 7 additions & 1 deletion src/platform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mod rust;
use self::rust::Rust;

mod fonky;
use self::fonky::Fonky;

pub trait Platform {
fn probe(&self) -> bool;

Expand All @@ -11,7 +14,10 @@ pub trait Platform {

pub fn probe() -> Option<Box<Platform>> {
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
Expand Down