cli: Fix exit code of parse subcommand
This commit is contained in:
parent
ccbb8c1cce
commit
af694b4c13
2 changed files with 9 additions and 4 deletions
|
|
@ -118,6 +118,7 @@ fn run() -> error::Result<()> {
|
|||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
let max_path_length = paths.iter().map(|p| p.chars().count()).max().unwrap();
|
||||
let mut has_error = false;
|
||||
for path in paths {
|
||||
let path = Path::new(path);
|
||||
let language =
|
||||
|
|
@ -129,7 +130,7 @@ fn run() -> error::Result<()> {
|
|||
eprintln!("No language found");
|
||||
return Ok(());
|
||||
};
|
||||
parse::parse_file_at_path(
|
||||
has_error |= parse::parse_file_at_path(
|
||||
language,
|
||||
path,
|
||||
max_path_length,
|
||||
|
|
@ -139,6 +140,10 @@ fn run() -> error::Result<()> {
|
|||
debug_graph,
|
||||
)?;
|
||||
}
|
||||
|
||||
if has_error {
|
||||
return Err(error::Error(String::new()));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn parse_file_at_path(
|
|||
print_time: bool,
|
||||
debug: bool,
|
||||
debug_graph: bool,
|
||||
) -> Result<()> {
|
||||
) -> Result<bool> {
|
||||
let mut _log_session = None;
|
||||
let mut parser = Parser::new();
|
||||
parser.set_language(language)?;
|
||||
|
|
@ -126,7 +126,7 @@ pub fn parse_file_at_path(
|
|||
let end = node.end_position();
|
||||
write!(
|
||||
&mut stdout,
|
||||
"\t({} [{}, {}] - [{}, {}]",
|
||||
"\t({} [{}, {}] - [{}, {}])",
|
||||
node.kind(),
|
||||
start.row,
|
||||
start.column,
|
||||
|
|
@ -137,5 +137,5 @@ pub fn parse_file_at_path(
|
|||
write!(&mut stdout, "\n")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(first_error.is_some())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue