owenrusk.dev

casebench

test cases straight onto the board.

git clone https://owenrusk.dev/casebench.git

commit 775f4be5a1248eff9b99f45e095b1073b90c1c97
parent cd2587571b8f4cdbc6960e10ff951e363fd789ec
author Owen Rusk <owen@papermothgames.com>
date   2025-04-09 16:41:03 -0500
note: -f to read the note from a file

notes with markdown in them don't survive the shell.
casebench/cli.py+5-2
diff --git a/casebench/cli.py b/casebench/cli.py
index 51297ba..d20c350 100644
--- a/casebench/cli.py
+++ b/casebench/cli.py
@@ -23,7 +23,9 @@ def main(argv: list[str] | None = None) -> int:
 
     note = sub.add_parser("note", help="write a note on a case")
     note.add_argument("case")
-    note.add_argument("text")
+    words = note.add_mutually_exclusive_group(required=True)
+    words.add_argument("text", nargs="?")
+    words.add_argument("-f", "--file", type=Path, help="read the note from a file")
     note.add_argument("--player", required=True)
     note.add_argument("--item", help="the item to write on; the case's title if left out")
     note.set_defaults(run=run_note)
@@ -64,5 +66,6 @@ def run_note(conn: psycopg.Connection, args: argparse.Namespace) -> None:
         raise Fail(f"{args.player} doesn't have {args.case}")
     if args.item and args.item not in db.items(conn, who, args.case):
         raise Fail(f"{args.case} has no item {args.item}")
-    db.note(conn, who, args.case, args.item, args.text)
+    text = args.file.read_text(encoding="utf-8") if args.file else args.text
+    db.note(conn, who, args.case, args.item, text)
     print(f"{args.player}: noted {args.case}" + (f" / {args.item}" if args.item else ""))