Support specifying content path in arguments
This commit is contained in:
parent
358e68c8db
commit
72fbcb42d6
|
@ -116,7 +116,7 @@
|
||||||
let content_fn = if args.no_content {
|
let content_fn = if args.no_content {
|
||||||
_ => []
|
_ => []
|
||||||
} else {
|
} else {
|
||||||
import "content/content.typ"
|
import "cache/content/content.typ"
|
||||||
content.content
|
content.content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
format.py
19
format.py
|
@ -5,6 +5,7 @@ import csv
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import string
|
import string
|
||||||
import typing
|
import typing
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
@ -160,6 +161,14 @@ parser.add_argument(
|
||||||
help="CSV file containing addresses",
|
help="CSV file containing addresses",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-i",
|
||||||
|
"--content-path",
|
||||||
|
default="content",
|
||||||
|
type=str,
|
||||||
|
help="Directory containing content files",
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-n",
|
"-n",
|
||||||
"--no-content",
|
"--no-content",
|
||||||
|
@ -216,6 +225,14 @@ for row in rows:
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Typst can't access files outside the project root, except through a symlink
|
||||||
|
# Create one in cache to use here
|
||||||
|
if not os.path.exists("cache"):
|
||||||
|
os.mkdir("cache")
|
||||||
|
p = pathlib.Path("cache/content")
|
||||||
|
p.unlink(missing_ok=True)
|
||||||
|
p.symlink_to(args.content_path)
|
||||||
|
|
||||||
cards = cards * args.count
|
cards = cards * args.count
|
||||||
|
|
||||||
serial = imb.get_first_serial()
|
serial = imb.get_first_serial()
|
||||||
|
@ -246,7 +263,7 @@ os.execlp(
|
||||||
"typst",
|
"typst",
|
||||||
"watch" if args.watch else "compile",
|
"watch" if args.watch else "compile",
|
||||||
"--font-path",
|
"--font-path",
|
||||||
"content",
|
args.content_path,
|
||||||
"--font-path",
|
"--font-path",
|
||||||
os.getenv("TYPST_FONT_PATHS"),
|
os.getenv("TYPST_FONT_PATHS"),
|
||||||
args.template,
|
args.template,
|
||||||
|
|
Loading…
Reference in a new issue