cmd

package
v0.0.0-...-c540820 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func SetVersion

func SetVersion(_version string)

SetVersion will set the version of the cmd package

func Version

func Version() string

Version will return the set version of cmd package

Types

type Context

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

Context is to store all command line Flags.

func NewContext

func NewContext(
	fs afero.Fs,
	primaryKeyPositions []int,
	valueColumnPositions []int,
	ignoreValueColumnPositions []int,
	includeColumnPositions []int,
	format string,
	baseFilename string,
	deltaFilename string,
	separator rune,
	lazyQuotes bool,
) (*Context, error)

NewContext can take all CLI flags and create a cmd.Context Validations are done as part of this. File pointers are created too.

func (*Context) BaseDigestConfig

func (c *Context) BaseDigestConfig() (digest.Config, error)

BaseDigestConfig creates a digest.Context from cmd.Context that is needed to start the diff process

func (*Context) Close

func (c *Context) Close()

Close all file handles

func (*Context) DeltaDigestConfig

func (c *Context) DeltaDigestConfig() (digest.Config, error)

DeltaDigestConfig creates a digest.Context from cmd.Context that is needed to start the diff process

func (Context) GetIncludeColumnPositions

func (c Context) GetIncludeColumnPositions() digest.Positions

GetIncludeColumnPositions is to return the --include flags as digest.Positions array. If empty, it is value columns

func (*Context) GetPrimaryKeys

func (c *Context) GetPrimaryKeys() digest.Positions

GetPrimaryKeys is to return the --primary-key flags as digest.Positions array.

func (*Context) GetValueColumns

func (c *Context) GetValueColumns() digest.Positions

GetValueColumns is to return the --columns flags as digest.Positions array.

type Formatter

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

Formatter can print the differences to stdout and accompanying metadata to stderr

func NewFormatter

func NewFormatter(stdout, stderr io.Writer, ctx Context) *Formatter

NewFormatter can be used to create a new formatter

func (*Formatter) Format

func (f *Formatter) Format(diff digest.Differences) error

Format can be used to format the differences based on ctx to appropriate writers

Jump to

Keyboard shortcuts

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