borealis-cli-example

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 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.

README

borealis-cli-example

The canonical borealis-style Go CLI exemplar — the copy-me template proving the pleme-io Go primitive fleet composes into the theory/BOREALIS.md §4 three-line-tool shape.

What

A small, real, demonstrative CLI that exercises the core borealis-style shape end to end. Every cross-cutting concern is wired the canonical way (BOREALIS §3.5), so the tool reads like the §4 worked example rather than a hand-rolled binary:

Concern Primitive How it shows up here
Configuration shikumi-go typed Config loaded once via shikumi.For[Config]…Load; config show path
CLI + help cli-go cli.App + subcommands + cli.Flag[T] (a OneOf/enum flag and a validator)
Presentation borealis borealis.Execute outermost (styled help/usage/errors) + borealis.Render
Logging logging-go structured slog logger from logging.FromConfig(cfg.Logging)
Errors + exit errors-go errs.Exit single funnel; one typed error mapped to a sysexits.h exit code

Commands:

  • version — print the tool identity, rendered through borealis.
  • config show — render the effective shikumi config; the secret-typed apiToken field is redacted by construction ([REDACTED]).
  • greet --name X --format text|json — a typed Flag[T] with a non-empty --name validator and a OneOf/enum --format flag, a logged structured action, and borealis-rendered output.

Why

The Borealis Theory's headline payoff is that producing a new, consistent, beautifully-helped pleme-io Go tool is a declarative act — config via shikumi.For, entrypoint via borealis.Execute, exit via errs.Exit — with no hand-rolled argv switch, no bespoke config loader, no os.Exit outside errs.Exit, and no fmt-based help. This repo is the executable proof of that claim and the template to copy when scaffolding a new tool.

main.go is deliberately the whole story:

func main() { errs.Exit(run(context.Background())) } // one exit funnel

func run(ctx context.Context) error {
    cfg, err := app.LoadConfig(ctx)            // 1. config — shikumi.For[Config]…Load
    if err != nil { return app.ErrConfig(err) }
    log, err := logging.FromConfig(cfg.Logging) // 2. logging — FromConfig
    if err != nil { return app.ErrConfig(err) }
    theme := borealis.Nord()                    // 3. theme — one bundle, one name
    root := app.New(cfg, log, theme)            // 4. grammar — typed cli-go App
    return exit.Map(borealis.Execute(ctx, root))// 5. entrypoint — borealis.Execute outermost
}

Install

# Nix (builds the binary):
nix build github:pleme-io/borealis-cli-example
./result/bin/borealis-cli-example --help

# Go:
go install github.com/pleme-io/borealis-cli-example@latest
Building from a local checkout (pre-publish)

The elevated *-go siblings are not yet tagged on proxy.golang.org, so the dev build resolves them locally via a go.work workspace (gitignored) plus a small set of go.mod replaces that break a versioned require cycle between shikumi-go and borealis. Both are removed at publish.

GOTOOLCHAIN=local go build ./...
GOTOOLCHAIN=local go test ./...

Usage

# styled help (borealis + fang) — help structure is DERIVED from typed data
borealis-cli-example --help

# tool identity, rendered through borealis
borealis-cli-example version

# the effective config (secret redacted)
BOREALIS_CLI_EXAMPLE_APITOKEN=hunter2 borealis-cli-example config show
#   greeting         Hello
#   locale           en
#   apiToken         [REDACTED]
#   logging.level    info
#   logging.format   json

# greet — typed Flag[T] + validator + OneOf/enum + logged action + render
borealis-cli-example greet --name Ada
borealis-cli-example greet --name Ada --format json

# a rejected flag maps to a typed exit code (EX_USAGE = 64)
borealis-cli-example greet --format yaml ; echo $?   # → 64
borealis-cli-example greet --name ''     ; echo $?   # → 64

Configuration

Config is a typed, yaml-tagged struct loaded once via shikumi.For[Config] (precedence args > env > file; a config file is optional — the tool runs on typed defaults + env alone). Knobs:

Field YAML / env Default Notes
greeting greeting / BOREALIS_CLI_EXAMPLE_GREETING Hello validated non-empty (required)
locale locale / BOREALIS_CLI_EXAMPLE_LOCALE en stamped onto the structured log line
apiToken apiToken / BOREALIS_CLI_EXAMPLE_APITOKEN — shikumi.Secret[string], always redacted
logging.level logging.level info debug / info / warn / error
logging.format logging.format json json / text / console / discard

Per-flag env overrides also exist for greet (BOREALIS_CLI_EXAMPLE_NAME, BOREALIS_CLI_EXAMPLE_FORMAT).

Example borealis-cli-example.yaml (discovered via XDG):

greeting: "Hola"
locale: "es"
apiToken: "secret://vault//prod/example/token"   # resolved by a backend resolver
logging:
  level: debug
  format: console

Release

Released via the pleme-io caixa SDLC pipeline. caixa.lisp (:kind :Binario, :ecosystem :go) is the single source of truth for the kind + release surface; flake.nix consumes substrate's goToolReleaseFlakeBuilder. Go uses the PULL release model — forge tool release tags and pushes a semver git tag; no artifact upload, proxy.golang.org fetches lazily.

nix run .#bump      # bump the semver in caixa.lisp + go module
nix run .#release   # tag vN.M.P + push (forge tool release --language go)

See CHANGELOG.md for the version history.

Documentation

Overview

Command borealis-cli-example is the canonical borealis-style Go CLI exemplar: the copy-me template proving the pleme-io primitive fleet composes into the section-4 three-line-tool shape (theory/BOREALIS.md §4).

It exercises the core shape end to end:

  • shikumi-go — a typed Config loaded once via shikumi.For[Config]…Load, surfaced by `config show` with the secret field redacted;
  • logging-go — a structured slog logger from logging.FromConfig(cfg.Logging);
  • cli-go — an App with subcommands and typed Flag[T] declarations, including a OneOf/enum --format flag and a --name validator;
  • borealis — borealis.Execute as the OUTERMOST entrypoint (styled help/usage/errors) and borealis.Render as the one output verb;
  • errors-go — errs.Exit as the single process-exit funnel, with one typed error mapped to a sysexits.h exit code.

The body below reads like the §4 worked shape: load → derive → execute → exit. There is no hand-rolled argv switch, no bespoke config loader, no os.Exit outside errs.Exit, and no fmt-based help.

Directories

Path Synopsis
internal
app
Package app builds the borealis-cli-example command tree.
Package app builds the borealis-cli-example command tree.

Jump to

Keyboard shortcuts

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