spec

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitIgnore  Exit = "ignore"
	ExitInverse Exit = "inverse"

	FileAppend  File = "append"
	FileDiscard File = "discard"

	OutputEmpty Output = "empty"
)

Variables

This section is empty.

Functions

func LooksLikeSpecFile

func LooksLikeSpecFile(info fs.DirEntry) bool

func ParseSpec

func ParseSpec(
	ctx context.Context,
	content []byte,
	s *Spec,
	source Source,
) error

Types

type Command added in v0.2.0

type Command struct {
	Command []string `yaml:"command"`
	Exit    Exit     `yaml:"exit,omitempty"`
	File    File     `yaml:"file,omitempty"`
	Global  bool     `yaml:"global,omitempty"`
	Output  Output   `yaml:"output,omitempty"`
}

type Exit added in v0.2.0

type Exit string

func (Exit) MarshalText added in v0.2.0

func (e Exit) MarshalText() (text []byte, err error)

func (Exit) String added in v0.2.0

func (e Exit) String() string

func (*Exit) UnmarshalText added in v0.2.0

func (e *Exit) UnmarshalText(text []byte) error

type File added in v0.2.0

type File string

func (File) MarshalText added in v0.2.0

func (f File) MarshalText() (text []byte, err error)

func (File) String added in v0.2.0

func (f File) String() string

func (*File) UnmarshalText added in v0.2.0

func (f *File) UnmarshalText(text []byte) error

type Output added in v0.2.0

type Output string

func (Output) MarshalText added in v0.2.0

func (o Output) MarshalText() (text []byte, err error)

func (Output) String added in v0.2.0

func (o Output) String() string

func (*Output) UnmarshalText added in v0.2.0

func (o *Output) UnmarshalText(text []byte) error

type Source

type Source func(ctx context.Context, location string) ([]byte, error)

func DefaultSource

func DefaultSource(workingDir string) Source

type Spec

type Spec struct {
	Location string `yaml:"-"`

	Exclude *pattern.Set `yaml:"exclude,omitempty"`
	Extends []string     `yaml:"extends,omitempty"`
	Tools   *ToolSet     `yaml:"tools,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	location string,
	source Source,
) (*Spec, error)

func (*Spec) Flatten

func (s *Spec) Flatten(ctx context.Context, source Source) error

func (*Spec) GetTools added in v0.1.2

func (s *Spec) GetTools(
	ctx context.Context,
	include, exclude []string,
) (tools *ToolSet, err error)

type Tool

type Tool struct {
	CheckCmd *YAMLCommand `yaml:"check,omitempty"`
	Exclude  *pattern.Set `yaml:"exclude,omitempty"`
	FixCmd   *YAMLCommand `yaml:"fix,omitempty"`
	Include  *pattern.Set `yaml:"include,omitempty"`
	Name     string       `yaml:"-"`
	Parse    string       `yaml:"parse,omitempty"`
	// contains filtered or unexported fields
}

func (*Tool) Compare

func (tool *Tool) Compare(other *Tool) int

func (*Tool) Includes

func (tool *Tool) Includes(
	ctx context.Context,
	f *file.File,
) (ok bool, err error)

func (*Tool) String

func (tool *Tool) String() string

type ToolSet

type ToolSet struct {
	util.SortedSet[*Tool]
}

func (*ToolSet) Load

func (ts *ToolSet) Load(
	ctx context.Context,
	name string,
) (tool *Tool, ok bool, err error)

func (*ToolSet) MarshalYAML

func (ts *ToolSet) MarshalYAML() (interface{}, error)

func (*ToolSet) Merge

func (ts *ToolSet) Merge(src reflect.Value) error

func (*ToolSet) UnmarshalYAML

func (ts *ToolSet) UnmarshalYAML(value *yaml.Node) error

type YAMLCommand added in v0.2.0

type YAMLCommand Command

func (*YAMLCommand) UnmarshalYAML added in v0.2.0

func (c *YAMLCommand) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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