cli

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cli contains shared runtime helpers for CLI binaries.

Package cli contains shared runtime helpers for CLI binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(app any, cfg Config, options ...kong.Option) (*kong.Kong, error)

New constructs a Kong parser for app with the provided runtime config.

func NewLogger

func NewLogger(level zerolog.Level) zerolog.Logger

NewLogger constructs the standard console logger for a CLI binary.

func Options

func Options(cfg Config) []kong.Option

Options returns the default Kong options for a CLI runtime config.

func Parse

func Parse(app any, cfg Config, options ...kong.Option) *kong.Context

Parse parses process arguments using the shared CLI runtime config.

func Run

func Run(ctx *kong.Context, log zerolog.Logger, args ...any) error

Run executes the selected Kong command with the shared logger injected first.

func SubLogger

func SubLogger(log zerolog.Logger, subsystem string) zerolog.Logger

SubLogger returns a logger rebound to the provided subsystem name.

Types

type BuildInfo

type BuildInfo struct {
	Name    string
	Version string
	Commit  string
}

BuildInfo describes resolved build metadata for a CLI binary.

func ResolveBuildInfo

func ResolveBuildInfo(name string) BuildInfo

ResolveBuildInfo returns build metadata with runtime build info fallbacks.

type Config

type Config struct {
	Description string
	BuildInfo   BuildInfo
}

Config defines shared runtime settings for parser construction.

Jump to

Keyboard shortcuts

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