banner

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Box(title string, lines ...string)

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

func BoxTo(w io.Writer, title string, lines ...string)

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

func Card(w io.Writer, left, right []string)

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

func Print(name string, port int, extras ...string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL