nifty_cli/check.rs
1//! `nf check`: report errors without running anything.
2
3use std::path::Path;
4use std::process::ExitCode;
5
6use crate::frontend::Sources;
7use crate::{CommandResult, EXIT_HAS_ERRORS, report};
8
9pub(crate) fn run(target: &Path) -> CommandResult {
10 let sources = Sources::read(target)?;
11 match sources.compile() {
12 Ok(_) => {
13 println!("{}: no problems found", sources.name());
14 Ok(ExitCode::SUCCESS)
15 }
16 Err(diagnostics) => {
17 report::print(&sources, &diagnostics)?;
18 Ok(ExitCode::from(EXIT_HAS_ERRORS))
19 }
20 }
21}