diff --git a/src/main.rs b/src/main.rs index e0cc252..b01c0d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ fn main() { loop { thread::sleep(time::Duration::from_millis(250)); let mut lights = lock.write().unwrap(); - let pattern = vec!["val".into(), "255".into(), "150".into(), "0".into()]; + let pattern = format_multiline("val 255 150 0"); let res = parse_line(pattern); if res.is_ok() { res.unwrap().execute(&mut lights); diff --git a/src/util.rs b/src/util.rs index 468fa36..115b28f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,3 @@ pub mod lights; -pub mod parser; pub mod pattern; pub mod webserver; \ No newline at end of file diff --git a/src/util/parser.rs b/src/util/parser.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/util/pattern.rs b/src/util/pattern.rs index d4cf2c9..30663eb 100644 --- a/src/util/pattern.rs +++ b/src/util/pattern.rs @@ -97,6 +97,11 @@ impl<'a> Pattern<'a> for Value { } pub fn parse_line<'a>(v: Vec) -> Result>, ParseError> { - let res: Result, ParseError> = v.try_into(); - res + v.try_into() } + +pub fn format_multiline(input: &str) -> Vec> { + input.lines() + .map(|x: &str| x.split_whitespace().collect::>()) + .collect() +} \ No newline at end of file