move cli functionality to a separate file

This commit is contained in:
Emi Vasilek 2023-11-18 18:15:34 +01:00
parent d3428354d2
commit 9e44070fe7
2 changed files with 44 additions and 22 deletions

View file

@ -1,6 +1,5 @@
from abc import abstractmethod
import collections
import sys
from typing import Dict, List, Any, Optional, Self, Set
import os
import json
@ -689,24 +688,3 @@ class Builder:
print("ERROR:", e)
return 1
return 0
def help() -> None:
print(f"usage: {sys.argv[0]} build DIR - build pages in DIR/out")
print(f" {sys.argv[0]} -h - show help")
def main() -> None:
if len(sys.argv) == 2 and sys.argv[1] == "-h":
help()
sys.exit(0)
elif len(sys.argv) == 3 and sys.argv[1] == "build":
ret = Builder().build(sys.argv[2])
sys.exit(ret)
else:
help()
sys.exit(1)
if __name__ == "__main__":
main()