43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""CLI: build a single FLP from a JSON song definition.
|
|
|
|
Usage:
|
|
python scripts/build_from_json.py <song.json> [--out <output.flp>]
|
|
"""
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, str(Path(__file__).parents[1]))
|
|
|
|
from src.flp_builder.schema import load_song_json
|
|
from src.flp_builder.builder import FLPBuilder
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="Build FLP from JSON song definition"
|
|
)
|
|
parser.add_argument("song_json", help="Path to song .json file")
|
|
parser.add_argument(
|
|
"--out", help="Output .flp path (default: same name as JSON)"
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
json_path = Path(args.song_json)
|
|
out_path = (
|
|
Path(args.out) if args.out else json_path.with_suffix(".flp")
|
|
)
|
|
|
|
song = load_song_json(json_path)
|
|
builder = FLPBuilder()
|
|
flp = builder.build(song)
|
|
|
|
out_path.write_bytes(flp)
|
|
print(f"Built {out_path} ({len(flp):,} bytes)")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|