import sys
from importlib import resources

from . import ascii_play


def _demo_path() -> str:
    path = resources.files("aaya_sher.assets").joinpath("demo.asv")
    with resources.as_file(path) as resolved:
        return str(resolved)


def main() -> None:
    argv = sys.argv[1:]
    if not argv or argv[0].startswith("-"):
        argv = [_demo_path()] + argv
        if "--loop" not in argv:
            argv.append("--loop")
        if "--speed" not in argv:
            argv.extend(["--speed", "0.28"])
    sys.argv = [sys.argv[0]] + argv
    ascii_play.main()


if __name__ == "__main__":
    main()
