kcl

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 15 Imported by: 35

Documentation

Overview

Package kcl defines the top-level interface for KCL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFullSchemaType added in v0.7.0

func GetFullSchemaType(pathList []string, schemaName string, opts ...Option) ([]*gpyrpc.KclType, error)

func GetSchemaType

func GetSchemaType(file, code, schemaName string) ([]*gpyrpc.KclType, error)

func GetSchemaTypeMapping added in v0.5.1

func GetSchemaTypeMapping(file, code, schemaName string) (map[string]*gpyrpc.KclType, error)

Types

type KCLResult

type KCLResult map[string]interface{}

func (KCLResult) Get

func (m KCLResult) Get(key string, target ...interface{}) interface{}

func (KCLResult) GetValue

func (m KCLResult) GetValue(key string, target ...interface{}) (value interface{}, err error)

func (KCLResult) JSONString

func (m KCLResult) JSONString() string

func (KCLResult) YAMLString

func (m KCLResult) YAMLString() string

type KCLResultList

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

func MustRun

func MustRun(path string, opts ...Option) *KCLResultList

func Run

func Run(path string, opts ...Option) (*KCLResultList, error)

func RunFiles

func RunFiles(paths []string, opts ...Option) (*KCLResultList, error)

func RunWithOpts

func RunWithOpts(opts ...Option) (*KCLResultList, error)

RunWithOpts is the same as Run, but it does not require a path as input. Note: you need to specify the path in options by method WithKFilenameList() or the workdir in method WorkDir(), or it will return an error.

func (*KCLResultList) First

func (p *KCLResultList) First() KCLResult

func (*KCLResultList) Get

func (p *KCLResultList) Get(i int) KCLResult

func (*KCLResultList) GetRawJsonResult

func (p *KCLResultList) GetRawJsonResult() string

func (*KCLResultList) GetRawYamlResult

func (p *KCLResultList) GetRawYamlResult() string

func (*KCLResultList) Len

func (p *KCLResultList) Len() int

func (*KCLResultList) Slice

func (p *KCLResultList) Slice() []KCLResult

func (*KCLResultList) Tail

func (p *KCLResultList) Tail() KCLResult

func (*KCLResultList) ToBool added in v0.7.2

func (p *KCLResultList) ToBool() (*bool, error)

ToBool returns the result as bool.

func (*KCLResultList) ToFloat64 added in v0.7.2

func (p *KCLResultList) ToFloat64() (*float64, error)

ToFloat64 returns the result as float64.

func (*KCLResultList) ToList added in v0.7.2

func (p *KCLResultList) ToList() ([]interface{}, error)

ToList returns the result as []interface{}.

func (*KCLResultList) ToMap added in v0.7.2

func (p *KCLResultList) ToMap() (map[string]interface{}, error)

ToMap returns the result as map[string]interface{}.

func (*KCLResultList) ToString added in v0.7.2

func (p *KCLResultList) ToString() (string, error)

ToString returns the result as string.

func (*KCLResultList) ToType added in v0.7.2

func (p *KCLResultList) ToType(target interface{}) error

ToType returns the result as target type.

type KclType

type KclType = gpyrpc.KclType

type Option

type Option struct {
	*gpyrpc.ExecProgram_Args

	Err error
	// contains filtered or unexported fields
}

func NewOption

func NewOption() *Option

NewOption returns a new Option.

func ParseArgs

func ParseArgs(pathList []string, opts ...Option) (Option, error)

func WithCode

func WithCode(codes ...string) Option

func WithDisableNone

func WithDisableNone(disableNone bool) Option

kcl -n --disable_none

func WithExternalPkgs

func WithExternalPkgs(key_value_list ...string) Option

kcl -E aaa=/xx/xxx/aaa main.k

func WithIncludeSchemaTypePath added in v0.5.4

func WithIncludeSchemaTypePath(includeSchemaTypePath bool) Option

WithIncludeSchemaTypePath returns a Option which hold a include schema type path switch.

func WithKFilenames

func WithKFilenames(filenames ...string) Option

func WithLogger added in v0.7.0

func WithLogger(l io.Writer) Option

func WithOptions

func WithOptions(key_value_list ...string) Option

kcl -D aa=11 -D bb=22 main.k

func WithOverrides

func WithOverrides(override_list ...string) Option

kcl -O pkgpath:path.to.field=field_value kcl -O pkgpath.path.to.field-

func WithOverridesError added in v0.7.0

func WithOverridesError(override_list ...string) (Option, error)

kcl -O pkgpath:path.to.field=field_value kcl -O pkgpath.path.to.field-

func WithPrintOverridesAST

func WithPrintOverridesAST(printOverrideAst bool) Option

func WithSelectors added in v0.7.0

func WithSelectors(selectors ...string) Option

kcl -S path.to.field

func WithSettings

func WithSettings(filename string) Option

kcl -Y settings.yaml

func WithSortKeys

func WithSortKeys(sortKeys bool) Option

kcl -k --sort_keys

func WithWorkDir

func WithWorkDir(s string) Option

func (*Option) GetLogger added in v0.7.0

func (p *Option) GetLogger() io.Writer

func (*Option) JSONString

func (p *Option) JSONString() string

func (*Option) Merge

func (p *Option) Merge(opts ...Option) *Option

Merge will merge all options into one.

Jump to

Keyboard shortcuts

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