Documentation
¶
Overview ¶
Package respfmt produces human-readable, styled renderings of game server responses. It exists so multiple CLIs (play_as, bulk-buy-order, future tools) can present command output the same way without each re-implementing the same struct unmarshal + table layout logic.
Public surface ¶
- Format(command, raw, opts...) — dispatch by command name, return the styled rendering or "" if no formatter is registered.
- Error(err, command) — friendly one-line error rendering, including command-specific overrides (e.g. mine "depleted" → "Ore depleted.").
- Per-command exports (Storage, Market, …) for callers that already know exactly which renderer they want.
Scope ¶
respfmt only produces styled output. Raw/JSON pass-through belongs in the caller. respfmt does not perform any I/O, network calls, or read from process state — every input is supplied via the function arguments.
Migration ¶
Formatters are being moved from cmd/tools/play_as/main.go in stages. The package is intentionally small at first; expect the surface to grow as each migration lands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBuyOrder ¶
CreateBuyOrder renders the action_result body of a create_buy_order command, listing failures explicitly. Returns "" if raw can't be parsed as the bulk-mode shape.
The accepted shapes are either the bare result body or the full action_result frame ({"command":..., "result":{...}}).
func CreateSellOrder ¶
CreateSellOrder mirrors CreateBuyOrder for sell-side orders.
func Error ¶
Error renders err as a single styled line.
If a (command, substring) pair in the override table matches, the friendly message is returned. Otherwise the raw error text is prefixed with "Error: ".
Callers that need transport-level context (e.g. "we're reconnecting, retry in a moment") should wrap this — Error makes no assumption about connection state. err must be non-nil; passing nil returns "".
Types ¶
type Option ¶
type Option func(*options)
Option configures a Format call. Reserved for per-command toggles that would otherwise need package-level state — e.g. a future WithFullDescriptions() to replace play_as's missionsShowFull bool.
func WithFullDescriptions ¶
func WithFullDescriptions() Option
WithFullDescriptions disables description truncation in formatters that would otherwise cap long bodies (e.g. missions).