From 27b3f5e9c8bdfbd63ec06cd0a3472f80ba8d3752 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 29 Nov 2016 20:45:55 -0800 Subject: small improvements to CLI tools --- src/bin/mt-tool.rs | 6 ++++-- src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bin/mt-tool.rs b/src/bin/mt-tool.rs index 7dab194..03f590a 100644 --- a/src/bin/mt-tool.rs +++ b/src/bin/mt-tool.rs @@ -100,8 +100,10 @@ fn main() { println!("{}", me.ast.repr_js().unwrap()); }, "list" => { - // XXX: search path? - for m in modelthing::search_models(Path::new("examples")) { + let search_path = + if matches.free.len() >= 2 { matches.free[1].clone() } + else { "examples".to_string() }; + for m in modelthing::search_models(Path::new(&search_path)) { println!("{}", m) } }, diff --git a/src/lib.rs b/src/lib.rs index 2a098ee..508eeec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,12 +108,12 @@ pub fn load_model_entry(p: &Path) -> Result { }) } -// TODO: have this check for model.modelica etc pub fn search_models(p: &Path) -> Vec { if fs::metadata(p).unwrap().is_dir() { fs::read_dir(p).unwrap() .map(|x| x.unwrap()) .filter(|x| x.metadata().unwrap().is_dir()) + .filter(|x| x.path().join("model.modelica").exists()) .map(|x| x.path().to_string_lossy().to_string()) .collect() } else { -- cgit v1.2.3