aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/default-face-summary.py
blob: 4a163eb4fa51c399d8f061556598124d865b8634 (plain)
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
#!/usr/bin/env python3
"""Print a concise summary of theme-studio's captured Emacs default faces."""

from __future__ import annotations

import json
import pathlib
import sys

from default_faces import DefaultFaces, changed_summary


HERE = pathlib.Path(__file__).resolve().parent


def main() -> None:
    paths = [pathlib.Path(p) for p in sys.argv[1:]]
    if not paths:
        paths = [HERE / "emacs-default-faces.json"]
    summaries = [DefaultFaces.from_path(path).summary() for path in paths]
    if len(summaries) == 1:
        print(json.dumps(summaries[0], indent=2, sort_keys=True))
    elif len(summaries) == 2:
        print(json.dumps(changed_summary(summaries[0], summaries[1]), indent=2, sort_keys=True))
    else:
        raise SystemExit("usage: default-face-summary.py [snapshot.json [snapshot-after.json]]")


if __name__ == "__main__":
    main()