This repository has been archived on 2026-09-16. You can view files and clone it, but cannot push or open issues or pull requests.
typst_reporter/diagnostics.typ

65 lines
1.8 KiB
Plaintext

#import "diagnostics-model.typ": diagnostics-model
#import "diagnostics-normalize.typ": normalize, datetime-day
#let diagnostics-file = sys.inputs.at("diagnostics", default: none)
#let author = sys.inputs.at("author", default: none)
#if diagnostics-file == none {
panic(
"Missing diagnostics input.\n" +
"Usage: typst compile --input diagnostics=diagnostics/file.json " +
"--input author=\"Your name\" diagnostics.typ output.pdf"
)
}
#if author == none or str.trim(str(author)) == "" {
panic(
"Missing required diagnostics author.\n" +
"Add: --input author=\"Your name\""
)
}
#let source = json(diagnostics-file)
#if source.at("report_type", default: "") != "windows_system_maintenance" {
panic(
"Unsupported diagnostics JSON.\n" +
"Expected report_type=\"windows_system_maintenance\" in " + diagnostics-file
)
}
#if source.at("schema_version", default: 0) != 1 {
panic(
"Unsupported WinDiagnostics schema version: " +
str(source.at("schema_version", default: "missing")) +
". This renderer currently supports schema_version 1."
)
}
#let rules = yaml("diagnostics-rules.yaml")
#let data = normalize(source, rules: rules, source-name: diagnostics-file)
#if datetime-day(source.at("generated_at", default: "")) == none {
panic(
"Missing required diagnostics date.\n" +
"The WinDiagnostics JSON must contain generated_at."
)
}
#let themes = yaml("themes.yaml")
#let theme-name = lower(str(sys.inputs.at("theme", default: "default")))
#if theme-name not in themes {
panic(
"Unknown diagnostics theme: \"" + theme-name + "\".\n" +
"Choose one of: " + themes.keys().join(", ")
)
}
#show: diagnostics-model.with(
data: data,
author: author,
theme: themes.at(theme-name),
logo: "assets/beffroi.png",
)