cli

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package cli provides a basic approach to manage parameters, which come either as part of the command line or/and via environment variable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager holds the main entities.

func New

func New() *Manager

New returns a new cli manager instance

func (*Manager) AddBoolParameter

func (m *Manager) AddBoolParameter(param *Parameter[bool])

AddBoolParameter adds a bool parameter to the manager. It sets the flagFunc and the envFunc.

func (*Manager) AddFloat64Parameter

func (m *Manager) AddFloat64Parameter(param *Parameter[float64])

AddFloat64Parameter adds a float64 parameter to the manager. It sets the flagFunc and the envFunc.

func (*Manager) AddIntParameter

func (m *Manager) AddIntParameter(param *Parameter[int])

AddIntParameter adds a int parameter to the manager. It sets the flagFunc and the envFunc.

func (*Manager) AddStringParameter

func (m *Manager) AddStringParameter(param *Parameter[string])

AddStringParameter adds a string parameter to the manager. It sets the flagFunc and the envFunc.

func (*Manager) Parse

func (m *Manager) Parse()

Parse does the whole execution. It handles the right order of the parameters origin. (cli arf or env var)

type Parameter

type Parameter[T any] struct {
	Name         string
	Usage        string
	DefaultValue T
	EnvVarName   string
	// contains filtered or unexported fields
}

Parameter holds the parameter configuration and the final value.

func NewParameter

func NewParameter[T any](name string, defaultValue T, usage, envVarName string) *Parameter[T]

NewParameter return a new parameter instance.

func (*Parameter[T]) GetValue

func (p *Parameter[T]) GetValue() *T

GetValue return the final value for the parameter.

Jump to

Keyboard shortcuts

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