61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
import argparse
|
|
import sys
|
|
|
|
from app.config import load_config
|
|
|
|
|
|
def _store(cfg):
|
|
import os
|
|
from photoflow.core import Store
|
|
os.makedirs(cfg.data_dir, exist_ok=True)
|
|
return Store(cfg.db_path).connect()
|
|
|
|
|
|
def _immich(deps, cfg):
|
|
if "immich" in deps:
|
|
return deps["immich"]
|
|
from photoflow.immich import ImmichClient
|
|
return ImmichClient(cfg.immich_url, cfg.immich_api_key)
|
|
|
|
|
|
def cmd_serve(deps) -> int:
|
|
from app import create_app
|
|
create_app(deps["config"]).run(host="0.0.0.0", port=8084)
|
|
return 0
|
|
|
|
|
|
def build_parser() -> argparse.ArgumentParser:
|
|
p = argparse.ArgumentParser(prog="categorize")
|
|
sub = p.add_subparsers(dest="command", required=True)
|
|
|
|
ing = sub.add_parser("ingest")
|
|
ing.add_argument("--from", dest="date_from")
|
|
ing.add_argument("--to", dest="date_to")
|
|
ing.add_argument("--tag")
|
|
ing.add_argument("--subset", type=int)
|
|
ing.add_argument("--full", action="store_true", help="ignore incremental updatedAfter")
|
|
|
|
cl = sub.add_parser("cluster")
|
|
cl.add_argument("--gap-factor", type=float, default=6.0)
|
|
|
|
sub.add_parser("serve")
|
|
|
|
ap = sub.add_parser("apply")
|
|
ap.add_argument("--yes", action="store_true", help="skip the confirmation prompt")
|
|
|
|
return p
|
|
|
|
|
|
def main(argv=None) -> int:
|
|
args = build_parser().parse_args(argv)
|
|
deps = {"config": load_config()}
|
|
if args.command == "serve":
|
|
return cmd_serve(deps)
|
|
# ingest / cluster / apply are wired in later tasks.
|
|
print(f"Command '{args.command}' is not implemented yet.")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|