format

package
v0.0.0-...-063aa45 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FmtCmd

type FmtCmd struct {
	// Name is the command name or path
	Name string

	// Args is a list of args to pass to the command.
	Args []string

	// Env is a map of additional env vars to pass to the command.
	Env mg.EnvMap

	// Langs is the list of languages in which the reducer should run
	Langs []mg.Lang

	// Actions is a list of actions on which the reducer is allowed to run.
	// The reducer always runs on the ViewFmt action, even if this list is empty.
	Actions []mg.Action
}

FmtCmd is wrapper around FmtFunc for generic fmt commands.

The view src is passed to the command's stdin. It takes care of handling command failure e.g. output on stderr or no output on stdout.

func (FmtCmd) Reduce

func (fc FmtCmd) Reduce(mx *mg.Ctx) *mg.State

Reduce implements the FmtCmd reducer.

type FmtFunc

type FmtFunc struct {
	// Fmt receives a copy of the view src and returns the fmt'ed src.
	//
	// Fmt should ideally fail in the face of any uncertainty
	// e.g. if running a command to do the formatting and it prints anything to stderr;
	// it should return an error because commands do not reliably return an error status.
	Fmt func(mx *mg.Ctx, src []byte) ([]byte, error)

	// Langs is the list of languages in which the reducer should run
	Langs []mg.Lang

	// Actions is a list of actions on which the reducer is allowed to run.
	// The reducer always runs on the ViewFmt action, even if this list is empty.
	Actions []mg.Action
}

FmtFunc is a reducer for generic fmt functions

it takes care of reading the view src and properly reporting any errors to the editor

func (FmtFunc) Reduce

func (ff FmtFunc) Reduce(mx *mg.Ctx) *mg.State

Reduce implements the FmtFunc reducer.

Jump to

Keyboard shortcuts

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