Documentation
¶
Overview ¶
Package banner prints a service startup banner with local + LAN URLs. Used by every service to give a consistent first impression in the terminal: name centered in a box, "Local:" and "Network:" URLs side by side so a phone on the same wifi can hit the LAN IP without copy-pasting.
╭──────────────────────────────────────────────────╮ │ service-edge │ ╰──────────────────────────────────────────────────╯ ➜ Local: http://localhost:8080 ➜ Network: http://192.168.1.42:8080
The optional `extras` argument accepts any number of trailing lines (e.g. a list of watched directories for the dev server) — each is printed verbatim after the URLs, indented with two spaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Box ¶
Box prints just the centered-title box, optionally followed by any number of free-form lines. CLI tools reuse the box style without dragging in port / URL concepts that don't apply to a one-shot command.
Each line in `lines` is printed verbatim after a two-space indent so it lines up under the box. Pass an empty string for blank-line separators.
Box targets stdout; BoxTo is the writer-aware variant for callers (CLI tools, tests) that need to capture or redirect the output.
func BoxTo ¶
BoxTo writes the centered-title box to w, followed by any free-form lines. It is the same drawing Box performs; Box is just the stdout convenience wrapper. Exposed so shared CLI scaffolding (service-tools/internal/clitool) can render the platform banner to a captured writer and stay testable.
func Card ¶
Card draws a fully-enclosed two-column box: a left art block (e.g. an ASCII logo) beside a right text block, like a business card. Unlike Box / Frame, the box width is computed from the content rather than the fixed boxWidth, so the card grows to fit the longest line. The shorter column is vertically centered against the taller one; pass an empty string in `right` for an intentional blank row (e.g. between a brand line and a property list).
Used by service-tools/internal/clitool for the HB Labs CLI welcome card (logo left, name/version/mail/web right).
func LAN ¶
func LAN() string
LAN returns the first non-loopback IPv4 address on any interface, or "" if none was found. Exported so callers can log the LAN IP separately if Print's full banner isn't appropriate.
func Print ¶
Print writes a server startup banner: the box with the service name, plus Local / Network URLs derived from the listen port.
- name the service title shown centered (e.g. "service-edge")
- port listen port; both Local + Network URLs use it
- extras optional lines printed below the URLs, verbatim with a two-space indent (caller decides bullets / spacing)
For non-server output (CLI tools, scripts) use Box instead, which draws the same box but skips the port / URL lines.
Types ¶
This section is empty.