program

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package program builds upon the Github packages knadh/koanf and urfave/cli/v3 to make it extremely simple to use the features of those two excellent packages in concert.

Every program using program will expose a standard set of command-line flags (--json, --log, --trace, --verbose) in addition to the standard flags provided by urfave/cli/v3 (--help and --version).

If a configuration struct is provided to the Run() function, then a further command=line flag (--config) is added to provide the source(s) of values for fields in the struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, command *cli.Command, options ...Option)

Run is the primary external function of this library. It augments the cli.Command with default command-line flags, hooks in handling for processing a configuration, runs the appropriate Action, calls the terminator to wait for goroutine cleanup

Types

type Configuration

type Configuration interface {
	Validate() error
}

Configuration is the interface for a configuration struct

type Option

type Option func(params ...any) error

Option is a functional parameter for Run()

func NoJSON

func NoJSON() Option

func NoLog

func NoLog() Option

func NoTrace

func NoTrace() Option

func NoVerbose

func NoVerbose() Option

func WithConfiguration

func WithConfiguration(config Configuration) Option

WithConfiguration is an Option helper to define a configuration structure that will be populated from the sources given on a --config command-line flag

Jump to

Keyboard shortcuts

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