-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstandalone_shell.py
More file actions
28 lines (22 loc) · 853 Bytes
/
Copy pathstandalone_shell.py
File metadata and controls
28 lines (22 loc) · 853 Bytes
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
from __future__ import annotations
import argparse
from pathlib import Path
from backend.app_shell import render_standalone_document
from tools.command_docs import command_doc
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog=command_doc("build", "standalone-shell").label,
description=command_doc("build", "standalone-shell").details,
)
parser.add_argument("output_path", nargs="?", type=Path)
return parser
def main(argv: list[str] | None = None) -> int:
parser = build_parser()
args = parser.parse_args(argv)
rendered = render_standalone_document()
if args.output_path is not None:
args.output_path.parent.mkdir(parents=True, exist_ok=True)
args.output_path.write_text(rendered, encoding="utf-8")
else:
print(rendered)
return 0