mirror repo of https://github.com/littlequartz/clink. a socket programming assignment for Sistem Terdistribusi
Client (main.go):
- Replace chat viewport/textarea with a simple order console UI using Bubble Tea + Huh forms
- Add types and messages for connection, menu loading, order submission, and status
- Implement connectCmd with short greeting drain; status updates on connect
- Implement fetchMenuCmd: send "MENU", parse single-line JSON into []menuItem
- Implement submitOrderCmd: send "ORDER <json>", read single-line ack
- Build interactive form (name, menu select, quantity, confirm) with validation
- Add model state for host, status/loading/error, lastOrder, and form fields
- Keyboard controls: n (new order), r (reconnect), q/esc/ctrl+c (quit)
- Simplify program start (remove pre-connect path); alt-screen only
- Remove chat colorization/regex, viewport, and textarea logic
Server (server.go):
- Define menuItem and order structs; add a defaultMenu
- Extend protocol:
- "MENU" returns single-line JSON array of menu items
- "ORDER <json>" validates name/item/quantity (with lenient quantity parsing)
- Acknowledge with "OK" or send "[error] ..." lines
- Optionally broadcast "[order] ..." to chat for visibility
- Keep existing chat behavior; integrate new commands alongside it
Notes:
- Server logs ORDER parsing and continues to support chat commands
- Error handling surfaces server-side errors to the client status/messages
|
||
|---|---|---|
| .github/workflows | ||
| .gitignore | ||
| build.sh | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| server.go | ||