jty

package
v0.0.0-...-8135b40 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOddInputFiles      = errors.New("odd number of file arguments received; must be given in pairs")
	ErrOddInputFilesStdin = errors.New(ErrOddInputFiles.Error() + " (ensure final item has terminating newline or NUL)")
	ErrNoInputFiles       = errors.New("at least one input-output pair must be given")

	ErrEncounteredErrors = errors.New("encountered errors during processing; failing")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Stdin          io.Reader
	Stdout, Stderr io.Writer

	FS afero.Fs
}

Command represents a running CLI environment.

func (*Command) Run

func (c *Command) Run(f *Flags) error

Run inputs all the CLI-specified files to a new Processor.

type Flags

type Flags struct {
	Args []string // The positional arguments.

	DryRun    bool
	FromStdin bool
	Zero      bool

	HelpRequested bool

	// Parsed --jpath values (in given order)
	// prefixed with JSONNET_PATH environment variable values in reverse order.
	// Same behavior as official jsonnet tool.
	JPaths []string
}

Flags are the command-line flags jty supports.

func (*Flags) AddToFlagSet

func (f *Flags) AddToFlagSet(s *pflag.FlagSet)

AddToFlagSet associates f with the given FlagSet.

func (*Flags) FinishParse

func (f *Flags) FinishParse(jsonnetPathEnv string)

FinishParse sets any default values that are implied by another option, and parses any supplied environment values.

jsonnetPathEnv is the value of environment variable JSONNET_PATH.

type Processor

type Processor struct {
	// If not nil, Processor will operate in dry run mode and write messages here.
	// Must be set before any calls to Process.
	DryRunDest io.Writer
	// contains filtered or unexported fields
}

Processor handles concurrent requests to process input Jsonnet files and save their output as YAML.

func NewProcessor

func NewProcessor(vm *jsonnet.VM, ioWorkers int, fs afero.Fs, logDest io.Writer) *Processor

NewProcessor returns a new Processor that has ioWorkers goroutines to handle reading input files and another ioWorkers goroutines to handle writing output files.

func (*Processor) Close

func (p *Processor) Close()

Close stops processing requests and blocks until outstanding requests have completed. After calling Close, calling Process again will panic.

func (*Processor) Process

func (p *Processor) Process(inPath, outPath string)

Process enqueues a request to compile the jsonnet at inPath and write the resulting YAML to outPath.

Jump to

Keyboard shortcuts

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