cli

package
v2.0.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cli is swarmcli's non-interactive command-line front-end. When the binary is invoked with arguments (e.g. `swarmcli charts install ...`) it runs a one-shot command that prints to stdout and exits, rather than launching the TUI. This is what makes charts usable from scripts, CI/CD and GitOps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(args []string, version string) int

Dispatch runs a non-interactive command and returns a process exit code. It is invoked from main when the binary is given arguments; an empty args slice is never passed (main launches the TUI in that case). version is the build version string for `swarmcli version`.

func RegisterCommand

func RegisterCommand(name, summary string, run func(args []string) int)

RegisterCommand adds a top-level verb served by a build embedding this module. Call it from init(), before Dispatch can run.

name is what the operator types (`swarmcli <name> …`), summary is the one line `swarmcli help` shows beside it, and run receives everything after the verb and returns the process exit code — 2 for a usage error, 1 for a failure, 0 for success, which is the contract every command here already keeps (see usageErr and fail).

It panics on a name that is empty, already registered, or one of this package's own verbs. All three are wiring errors fixed at compile-authoring time and reachable from no input, and the alternative — quietly ignoring the registration, or quietly shadowing `version` — is a binary that behaves differently from the source somebody is reading. Precedent: sql.Register and http.ServeMux both panic on a duplicate.

func SetEdition

func SetEdition(e string)

SetEdition records which artefact this build is (called from main).

Types

This section is empty.

Jump to

Keyboard shortcuts

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