Skip to content

Commit

Permalink
Refactor print_health
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Mar 30, 2022
1 parent 42a06ec commit 5496c27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 8 additions & 9 deletions helix-term/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,14 @@ fn probe_treesitter_feature(lang: &str, feature: TsFeature) -> std::io::Result<(
}

pub fn print_health(health_arg: Option<String>) -> std::io::Result<()> {
if let Some(lang) = health_arg {
match lang.as_str() {
"all" => languages_all(),
_ => language(lang),
}?;
} else {
general()
.and_then(|_| writeln!(std::io::stdout().lock()))
.and_then(|_| languages_all())?;
match health_arg.as_deref() {
Some("all") => languages_all()?,
Some(lang) => language(lang.to_string())?,
None => {
general()?;
writeln!(std::io::stdout().lock())?;
languages_all()?;
}
}
Ok(())
}
2 changes: 2 additions & 0 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ FLAGS:

if args.health {
if let Err(err) = helix_term::health::print_health(args.health_arg) {
// Piping to for example `head -10` requires special handling:
// https://stackoverflow.com/a/65760807/7115678
if err.kind() != std::io::ErrorKind::BrokenPipe {
return Err(err.into());
}
Expand Down

0 comments on commit 5496c27

Please sign in to comment.