Add parse subcommand

Co-Authored-By: Timothy Clem <timothy.clem@gmail.com>
This commit is contained in:
Max Brunsfeld 2019-01-07 17:57:36 -08:00
parent 8291d294fb
commit 20fcffb393
2 changed files with 78 additions and 0 deletions

View file

@ -86,6 +86,15 @@ fn run() -> error::Result<()> {
eprintln!("No language found");
}
}
if let Some(matches) = matches.subcommand_matches("parse") {
loader.find_parsers(&vec![home_dir.join("github")])?;
let source_path = Path::new(matches.value_of("path").unwrap());
if let Some((language, _)) = loader.language_for_file_name(source_path)? {
parse::parse_file_at_path(language, source_path)?;
} else {
eprintln!("No language found");
}
}
Ok(())