filetypes

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTagsForInterpretation added in v0.11.0

func DefaultTagsForInterpretation(interp build.Interpretation, mode Mode) map[string]bool

DefaultTagsForInterpretation returns any tags that would be set by default in the given interpretation in the given mode.

func IsPackage

func IsPackage(s string) bool

IsPackage reports whether a command-line argument is a package based on its lexical representation alone.

func ParseArgs

func ParseArgs(args []string) (files []*build.File, err error)

ParseArgs converts a sequence of command line arguments representing files into a sequence of build file specifications.

The arguments are of the form

file* (spec: file+)*

where file is a filename and spec is itself of the form

tag[=value]('+'tag[=value])*

A file type spec applies to all its following files and until a next spec is found.

Examples:

json: foo.data bar.data json+schema: bar.schema

func ParseFile

func ParseFile(s string, mode Mode) (*build.File, error)

ParseFile parses a single-argument file specifier, such as when a file is passed to a command line argument.

Example:

cue eval -o yaml:foo.data

func ParseFileAndType added in v0.10.0

func ParseFileAndType(file, scope string, mode Mode) (*build.File, error)

ParseFileAndType parses a file and type combo.

Types

type FileInfo

type FileInfo struct {
	*build.File

	Definitions  bool `json:"definitions"`  // include/allow definition fields
	Data         bool `json:"data"`         // include/allow regular fields
	Optional     bool `json:"optional"`     // include/allow definition fields
	Constraints  bool `json:"constraints"`  // include/allow constraints
	References   bool `json:"references"`   // don't resolve/allow references
	Cycles       bool `json:"cycles"`       // cycles are permitted
	KeepDefaults bool `json:"keepDefaults"` // select/allow default values
	Incomplete   bool `json:"incomplete"`   // permit incomplete values
	Imports      bool `json:"imports"`      // don't expand/allow imports
	Stream       bool `json:"stream"`       // permit streaming
	Docs         bool `json:"docs"`         // show/allow docs
	Attributes   bool `json:"attributes"`   // include/allow attributes
}

FileInfo defines the parsing plan for a file.

func FromFile

func FromFile(b *build.File, mode Mode) (*FileInfo, error)

FromFile return detailed file info for a given build file. Encoding must be specified. TODO: mode should probably not be necessary here.

type Mode

type Mode int

Mode indicate the base mode of operation and indicates a different set of defaults.

const (
	Input Mode = iota // The default
	Export
	Def
	Eval
)

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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