cparam

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TypeStringParam  = "string"
	TypeChoicesParam = "choices"
)

params types

Variables

This section is empty.

Functions

This section is empty.

Types

type ChoiceParam

type ChoiceParam struct {
	InputParam
	// Choices for select
	Choices []string
	// contains filtered or unexported fields
}

ChoiceParam definition

func NewChoiceParam

func NewChoiceParam(name, desc string) *ChoiceParam

NewChoiceParam instance

func (*ChoiceParam) Run

func (p *ChoiceParam) Run() (err error)

Run param and get user input

func (*ChoiceParam) Selected

func (p *ChoiceParam) Selected() string

Selected values get

func (*ChoiceParam) Set

func (p *ChoiceParam) Set(v string) error

Set value

func (*ChoiceParam) WithChoices

func (p *ChoiceParam) WithChoices(Choices []string) *ChoiceParam

WithChoices to param definition

type ChoicesParam added in v3.2.0

type ChoicesParam struct {
	InputParam
	// Choices for select
	Choices []string
	// contains filtered or unexported fields
}

ChoicesParam definition

func NewChoicesParam added in v3.2.0

func NewChoicesParam(name, desc string) *ChoicesParam

NewChoicesParam instance

func (*ChoicesParam) Run added in v3.2.0

func (p *ChoicesParam) Run() (err error)

Run param and get user input

func (*ChoicesParam) Selected added in v3.2.0

func (p *ChoicesParam) Selected() []string

Selected values get

func (*ChoicesParam) Set added in v3.2.0

func (p *ChoicesParam) Set(v string) error

Set value

func (*ChoicesParam) WithChoices added in v3.2.0

func (p *ChoicesParam) WithChoices(Choices []string) *ChoicesParam

WithChoices to param definition

type InputParam

type InputParam struct {

	// Default value
	Default any
	ValidFn func(val string) error
	// contains filtered or unexported fields
}

InputParam struct

func NewInputParam

func NewInputParam(typ, name, desc string) *InputParam

NewInputParam instance

func (*InputParam) Desc

func (p *InputParam) Desc() string

Desc message

func (*InputParam) Name

func (p *InputParam) Name() string

Name get

func (*InputParam) Run

func (p *InputParam) Run() (err error)

Run param and get user input

func (*InputParam) Set

func (p *InputParam) Set(v string) error

Set value and with validate

func (*InputParam) SetFunc

func (p *InputParam) SetFunc(fn RunFn)

SetFunc for run

func (*InputParam) SetValidFn

func (p *InputParam) SetValidFn(fn func(val string) error)

SetValidFn for run

func (*InputParam) String

func (p *InputParam) String() string

Value get

func (*InputParam) Type

func (p *InputParam) Type() string

Type name get

func (*InputParam) Valid

func (p *InputParam) Valid(v string) error

Valid value validate

func (*InputParam) Value

func (p *InputParam) Value() structs.Value

Value data get

type RunFn

type RunFn func() (val string, err error)

RunFn func type

type StringParam

type StringParam struct {
	InputParam
}

StringParam definition

func NewStringParam

func NewStringParam(name, desc string) *StringParam

NewStringParam instance

func (*StringParam) Config

func (p *StringParam) Config(fn func(p *StringParam)) *StringParam

Config param

func (*StringParam) Run

func (p *StringParam) Run() (err error)

Run param and get user input

Jump to

Keyboard shortcuts

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