This introduces the FastAPI editor implementation and related project setup so the app can be run and validated locally. Made-with: Cursor
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
def main() -> int:
|
|
workspace_root = Path(__file__).resolve().parents[1]
|
|
prompts_root = workspace_root / "prompts"
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: demo_prompt_args.py <prompt-folder>")
|
|
print("Example: demo_prompt_args.py test")
|
|
return 1
|
|
|
|
prompt_folder = sys.argv[1].strip().strip("/")
|
|
if not prompt_folder:
|
|
print("Error: prompt folder arg is empty.")
|
|
return 1
|
|
|
|
target_dir = prompts_root / prompt_folder
|
|
if not target_dir.exists() or not target_dir.is_dir():
|
|
print(f"Error: prompts folder not found: {target_dir}")
|
|
return 1
|
|
|
|
txt_files = sorted(target_dir.glob("*.txt"))
|
|
if not txt_files:
|
|
print(f"No .txt files found in prompts/{prompt_folder}")
|
|
return 0
|
|
|
|
print(f"Reading {len(txt_files)} prompt file(s) from prompts/{prompt_folder}")
|
|
for txt_file in txt_files:
|
|
print(f"\n--- {txt_file.name} ---")
|
|
print(txt_file.read_text(encoding="utf-8"))
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|