Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

Commit 578e4bb

Browse files
committed
feat: load modtime
1 parent 4d2d7ac commit 578e4bb

3 files changed

Lines changed: 72 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ description = "Add your description here"
55
readme = "README.md"
66
authors = [{ name = "faretek", email = "r@faretek.dev" }]
77
requires-python = ">=3.12"
8-
dependencies = []
8+
dependencies = [
9+
"gitpython>=3.1.46",
10+
]
911

1012
[project.scripts]
1113
sb2git = "sb2git:main"

src/sb2git/__init__.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import argparse
22
import typing as t
3+
from pathlib import Path
4+
from datetime import datetime
35

46

57
class ArgNamespace(argparse.Namespace):
8+
command: t.Literal["init", "build"]
69
path: str
10+
output: str
711

812

913
def main() -> None:
@@ -14,10 +18,36 @@ def main() -> None:
1418
"gh: https://github.com/scratch-api/sb2git",
1519
)
1620

17-
parser.add_argument("path", type=str)
21+
if command := parser.add_subparsers(dest="command", required=True):
22+
if init := command.add_parser("init", help="Set up a sb2git.toml file"):
23+
init.add_argument("path", nargs="?", default=".", type=str)
24+
if build := command.add_parser(
25+
"build", help="Build a sb2git input directory into an output directory"
26+
):
27+
build.add_argument(
28+
"-o", "--output", type=str, default="build", help="Output directory"
29+
)
1830
args = parser.parse_args(namespace=ArgNamespace())
1931
run(args)
2032

2133

2234
def run(args: ArgNamespace):
23-
print(f"Hello from sb2git! {args}")
35+
match args.command:
36+
case "init":
37+
init(args)
38+
case "build":
39+
...
40+
41+
42+
def init(args: ArgNamespace):
43+
path = Path(args.path).resolve()
44+
if not path.exists():
45+
raise ValueError(f"{path} does not exist")
46+
47+
print(f"Walking {args.path}")
48+
for file in path.iterdir():
49+
created_at = datetime.fromtimestamp(file.stat().st_mtime)
50+
print(file, created_at)
51+
52+
53+
def build(args: ArgNamespace): ...

uv.lock

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)