sxcli.devSimple Extensible CLI
You are viewing an archived snapshot (v0.1.0). Switch to the current version →

Overview

sxcli-fw — Simple Extensible CLI — is a Go framework for building command-line tools and services around one idea: your configuration struct is your entire interface. Declare a struct once and every field is simultaneously a command-line argument, an environment variable, and a config-file key — merged with clear precedence, validated strictly, and handed to your code filled in. Around that sit services, dependency injection, an ordered lifecycle — and, when you want it, busybox-style multi-applet binaries.

The model#

Everything is a service: a struct registered under an id. An applet is a service implementing the Applet interface — Configured() error plus Run() int — the dispatchable entry point. Services declare dependencies with struct tags, and the framework resolves the applet's dependency closure, configures and starts its members in dependency order, runs the applet, and stops everything in reverse.

go
go
type Backup struct {
    Store *BoltStore   `inject:""`          // by concrete type
    Log   slog.Handler `inject:";optional"` // by interface, optional
}

What you get#

  • Dispatch by argv[0] (symlink style) or by first subcommand argument — or neither, in single-applet binaries.
  • Configuration merged from defaults, config files, environment and arguments, driven by one struct per service.
  • Dependency injection between services, resolved before anything runs.
  • Lifecycle: ConfiguredStartRunStop, dependency-ordered, sequential by design.
  • Logging on log/slog with pluggable sinks: console, file, syslog/journald.
  • Introspection: a read-only composition view — applets, services, closure-true argument schemas — for building completions and doc generators as services.
  • Windows service support: the same applet runs as a console process or under the SCM.

Design principles#

The framework is deliberately boring where it counts: lifecycle calls are sequential (no concurrency in the core), startup failures report all problems at once instead of one at a time, and misconfiguration is a loud startup error, never a silent skip.

Status#

v0 — the API is settling and may still move. Module path sxcli.dev/fw, Go 1.26+, licensed under Apache-2.0.

Continue with Getting started.