from pathlib import Path

from .. import collection
from ..collection import file, ingest, raytracing

csi_producer: collection.CSIProducer = collection.NoopCSIProducer()
is_live = True


def main(from_file: Path | None = None, from_environment: Path | None = None) -> None:
    global csi_producer, is_live
    if from_file and from_environment:
        raise ValueError("Cannot specify both a data file and an environment file")
    if from_file:
        csi_producer = file.FileCSIPRoducer(path=from_file)
    elif from_environment:
        environment = raytracing.Environment.from_config(from_environment)
        csi_producer = raytracing.SimulatedCSIProducer(environment)
    else:
        csi_producer = ingest.RealtimeCSIProducer()
