65 lines
1.8 KiB
Plaintext
65 lines
1.8 KiB
Plaintext
#import "modules/diagnostics-model.typ": diagnostics-model
|
|
#import "modules/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) not in (1, 2) {
|
|
panic(
|
|
"Unsupported WinDiagnostics schema version: " +
|
|
str(source.at("schema_version", default: "missing")) +
|
|
". This renderer currently supports schema_version 1 and 2."
|
|
)
|
|
}
|
|
|
|
#let rules = yaml("config/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("config/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",
|
|
)
|