cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cli is the plumbing fiberd's commands share. Run picks the subcommand of grant-issuer or zygotectl and turns its outcome into an exit code. ParseFlags marks a flag error as a usage error. Version is what every command's -version prints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFlags

func ParseFlags(fs *flag.FlagSet, args []string, stderr io.Writer) error

ParseFlags parses args into fs, which reports its own errors to stderr.

func Run

func Run(args []string, usage string, cmds map[string]Command, stderr io.Writer) int

Run dispatches args[0] to its command and returns the exit code. It is 0 on success or -h, 2 for a usage error, and 1 when the command fails. No subcommand, help, or an unknown one prints usage to stderr. A failure is logged to stderr.

func Version

func Version(stamped string) string

Version is what a binary's -version prints. stamped is the binary's main.version, which a release sets at link time with -ldflags "-X main.version=v0.1.0". An unstamped build reports the module version Go recorded, as go install does, and otherwise "dev".

Types

type Command

type Command func(args []string) error

Command runs one subcommand on the arguments after its name.

Jump to

Keyboard shortcuts

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