Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for using shadergarden through standard input and piping #12

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
added reading config from stdin
  • Loading branch information
jar2333 committed Jan 5, 2023
commit ad1427a90b82a0901d9c61db50020107b881bb6e
20 changes: 14 additions & 6 deletions src/reload/shader_dir.rs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ use std::{
collections::BTreeMap,
ffi::OsStr,
fs,
io,
path::Path,
};

@@ -72,12 +73,19 @@ impl ShaderDir {
where
T: AsRef<Path>,
{
let lisp = fs::read_to_string(&config).map_err(|_| {
format!(
"Could not read `{}` in shader directory",
config.as_ref().to_str().unwrap()
)
})?;
let lisp =
if config.as_ref().to_str().unwrap() == "-" {
io::read_to_string(io::stdin()).map_err(|_| {
"Could not read config in stdin"
})?
} else {
fs::read_to_string(&config).map_err(|_| {
format!(
"Could not read `{}` in shader directory",
config.as_ref().to_str().unwrap()
)
})?
};

let mut shaders = BTreeMap::new();
let files = fs::read_dir(path)