-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathgithub.rs
More file actions
45 lines (40 loc) · 1.45 KB
/
github.rs
File metadata and controls
45 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary};
use pglt_console::{Console, ConsoleExt, markup};
use pglt_diagnostics::PrintGitHubDiagnostic;
use std::io;
pub(crate) struct GithubReporter {
pub(crate) diagnostics_payload: DiagnosticsPayload,
pub(crate) execution: Execution,
}
impl Reporter for GithubReporter {
fn write(self, visitor: &mut dyn ReporterVisitor) -> io::Result<()> {
visitor.report_diagnostics(&self.execution, self.diagnostics_payload)?;
Ok(())
}
}
pub(crate) struct GithubReporterVisitor<'a>(pub(crate) &'a mut dyn Console);
impl ReporterVisitor for GithubReporterVisitor<'_> {
fn report_summary(
&mut self,
_execution: &Execution,
_summary: TraversalSummary,
) -> io::Result<()> {
Ok(())
}
fn report_diagnostics(
&mut self,
_execution: &Execution,
diagnostics_payload: DiagnosticsPayload,
) -> io::Result<()> {
for diagnostic in &diagnostics_payload.diagnostics {
if diagnostic.severity() >= diagnostics_payload.diagnostic_level {
if diagnostic.tags().is_verbose() && diagnostics_payload.verbose {
self.0.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
} else if !diagnostics_payload.verbose {
self.0.log(markup! {{PrintGitHubDiagnostic(diagnostic)}});
}
}
}
Ok(())
}
}