common

package
v0.29.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InputTypeArray   = "Array"
	InputTypeBoolean = "boolean"
	InputTypeFloat   = "float"
	InputTypeHash    = "Hash"
	InputTypeInteger = "integer"
	InputTypeList    = "list"
	InputTypeNumber  = "number"
	InputTypeString  = "string"
	InputTypeAny     = ""
)
View Source
var (
	OutputTypeArray   = "Array"
	OutputTypeBoolean = "boolean"
	OutputTypeFloat   = "float"
	OutputTypeHash    = "Hash"
	OutputTypeInteger = "integer"
	OutputTypeList    = "list"
	OutputTypeNumber  = "number"
	OutputTypeString  = "string"
	OutputTypeAny     = ""
)

Functions

func EachFile

func EachFile(kind string, libdirs []string, cb func(name string, path string) (br bool))

EachFile calls cb with a path to every found DD of type kind, stops looking when br is true

func ValToDDLType

func ValToDDLType(typedef string, val string) (res any, err error)

ValToDDLType converts val into the type described in typedef where typedef is a typical choria DDL supported type

Types

type InputItem

type InputItem struct {
	Prompt      string   `json:"prompt"`
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Default     any      `json:"default,omitempty"`
	Optional    bool     `json:"optional"`
	Validation  string   `json:"validation,omitempty"`
	MaxLength   int      `json:"maxlength,omitempty"`
	Enum        []string `json:"list,omitempty"`
}

InputItem describes an individual input item

func (*InputItem) ConvertStringValue

func (i *InputItem) ConvertStringValue(val string) (any, error)

ConvertStringValue converts a string representing value into the correct type according to the input Type

func (*InputItem) RenderConsole added in v0.22.0

func (i *InputItem) RenderConsole() ([]byte, error)

func (*InputItem) RenderMarkdown added in v0.22.0

func (i *InputItem) RenderMarkdown() ([]byte, error)

func (*InputItem) Required

func (i *InputItem) Required() bool

Required indicates if this item is required

func (*InputItem) ValidateStringValue

func (i *InputItem) ValidateStringValue(val string) (converted any, warnings []string, err error)

ValidateStringValue converts a value to the appropriate type for this input then validates it

func (*InputItem) ValidateValue

func (i *InputItem) ValidateValue(val any) (warnings []string, err error)

ValidateValue validates a value against this input, should be of the right data type already. See ValToDDLType()

type OutputItem

type OutputItem struct {
	Description string `json:"description"`
	DisplayAs   string `json:"display_as"`
	Default     any    `json:"default,omitempty"`
	Type        string `json:"type,omitempty"`
}

OutputItem describes an individual output item

func (*OutputItem) RenderConsole added in v0.22.0

func (i *OutputItem) RenderConsole() ([]byte, error)

func (*OutputItem) RenderMarkdown added in v0.22.0

func (i *OutputItem) RenderMarkdown() ([]byte, error)

Jump to

Keyboard shortcuts

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