forked from adl-lang/adl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::path::PathBuf; | ||
|
||
use super::VerifyOpts; | ||
|
||
use crate::processing::loader::{MultiLoader, DirTreeLoader, AdlLoader}; | ||
|
||
pub fn verify(opts: &VerifyOpts) { | ||
let mut loader = loader_from_search_paths(&opts.searchdir); | ||
for m in &opts.modules { | ||
let lm = loader.load(m); | ||
match lm { | ||
Ok(Some(_)) => println!("Verified module {}", m), | ||
Ok(None) => println!("Failed to find module {}", m), | ||
Err(e) => println!("Failed to verify module {}: {}", m, e), | ||
|
||
} | ||
} | ||
} | ||
|
||
pub fn loader_from_search_paths(paths: &Vec<PathBuf>) -> Box<dyn AdlLoader> { | ||
let loaders = paths.iter().map(loader_from_dir_tree).collect(); | ||
Box::new(MultiLoader::new(loaders)) | ||
} | ||
|
||
pub fn loader_from_dir_tree(path: &PathBuf) -> Box<dyn AdlLoader> { | ||
Box::new(DirTreeLoader::new(path.clone())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
use compiler::cli::CliOptions; | ||
use compiler::cli::{CliOptions, Command}; | ||
use gumdrop::Options; | ||
|
||
use compiler::cli::verify::verify; | ||
|
||
fn main() { | ||
let opts = CliOptions::parse_args_default_or_exit(); | ||
|
||
match opts.command { | ||
None => println!("{}", CliOptions::usage()), | ||
Some(cmd) => println!("{:#?}", cmd), | ||
None => println!("{}", CliOptions::self_usage(&opts)), | ||
Some(Command::Verify(opts)) => verify(&opts), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters