blob: 7d2aa921d93bca0ea4d451d65b5b4bf6675187d6 (
plain) (
blame)
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
|
#!/usr/bin/env nu
# Generate JSON from jj log and compile a Typst document
# Usage: nu build/jj-log.nu [--revset '::@'] [--output build/jj-log.pdf]
def main [
--revset (-r): string = "::@" # jj revset expression
--output (-o): string = "build/jj-log.pdf" # output PDF path
--json-only (-j) # only generate JSON, skip typst compile
] {
let build_dir = ($env.FILE_PWD? | default ("build" | path expand))
let tmpl = (open ([$build_dir "jj-log.tmpl"] | path join))
let json_path = ($output | path parse | update extension "json" | path join)
let trees_json = "trees/_data/jj-log.json"
mkdir trees/_data
print $"generating log for revset: ($revset)"
let log_output = (jj log -r $revset --no-graph -T $tmpl)
$log_output | save -f $json_path
$log_output | save -f $trees_json
let n = (open --raw $json_path | lines | where $it != "" | length)
print $"wrote ($n) entries to ($json_path), ($trees_json)"
if not $json_only {
let typ_path = ([$build_dir "jj-log.typ"] | path join)
let json_abs = ($json_path | path expand)
let out_abs = ($output | path expand)
print $"compiling ($output)..."
typst compile $typ_path --root / --input $"data=($json_abs)" $out_abs
print $"done → ($output)"
}
}
|