Skip to content

Playing a game from the terminal

Each platform has a CLI that speaks spec/protocol/cli.md: one request per line on stdin, one JSON response per line on stdout. Build one (for example cd rust && cargo build -p canasta-cli) and run it from the repo root:

rust/target/debug/canasta-cli --spec spec
ls
do newGame {"ruleSet":"official","players":4,"dealer":0,"seed":15,"stream":54}
do draw {"seat":1}
do lay {"seat":1,"melds":[["AS","AD","AD"]]}
do discard {"seat":1,"card":"KS"}

ls prints the focused screen: its state and every action with its JSON input schema. You play every seat: read state.turn and state.seats[n].hand, then act. A refused move answers {"ok":false,"error":{"kind":"rule","code":"pileFrozen",...}} and changes nothing. The behaviour suite in spec/behaviour/ drives all three CLIs the same way.