Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

main: add on_start/on_end lifecycle hooks

author: pi66
date: 2026-07-21 10:15
hash: 9d13b7a7088aad47ee9041fad12c899054c67f91

Diffstat:

M

src/main.py
7 ++++++++++++++++++++++++++++++
 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
diff --git a/src/main.py b/src/main.py
index 780d6fa..0a08d51 100755
--- a/src/main.py
+++ b/src/main.py
@@ -1,10 +1,12 @@
 import sys
 sys.dont_write_bytecode = True

+import atexit
 from argparse import ArgumentParser
 from os import environ
 from .log import *
 from . import settings
+from .hooks import hook_call

 def main():
     common = ArgumentParser(add_help=False)
@@ -33,6 +35,8 @@ def main():
     settings.VERBOSE  =  args.verbose  or ( environ.get("VERBOSE")  in ["true", "1"])
     settings.NO_COLOR =  args.no_color or ( environ.get("NO_COLOR") in ["true", "1"])

+    hook_call("on_start")
+
     if args.command == "init":
         from .init_project import init
         init(project_path = args.path)
@@ -48,3 +52,6 @@ def main():
     elif args.command == "watch":
         from .watcher import run_watcher
         run_watcher(args.path)
+
+    atexit.register(lambda: hook_call("on_end"))
+