process

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegex *regexp.Regexp = regexp.MustCompile(`/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/`)

Functions

This section is empty.

Types

type Action

type Action int

Action performed when processing a file

const (
	// SkippedAdd means that the file had no license but the new one was not added.
	// as the -a flag was not provided
	SkippedAdd Action = iota
	// SkippedReplace means that the file had a different license but it was not
	// replaced with the target one as the -r flag was not provided
	SkippedReplace
	// LicenseOk means that the license was OK so the file was not changed
	LicenseOk
	// LicenseAdded means that the target license was added to the file
	LicenseAdded
	// LicenseReplaced means that the file's license was replaced by the target one
	LicenseReplaced
	// OperationError means there was an error with one of the files
	OperationError
)

func File

func File(path string, content string, license string, options *Options, h fileHandler) Action

File processes one file

type Operation

type Operation struct {
	Action Action
	Path   string
}

Operation is the result of processing one file

type Options

type Options struct {
	Add         bool
	Replace     bool
	Path        string
	LicensePath string
	Extensions  []string
	IgnorePaths []string
	HeaderRegex *regexp.Regexp
}

Options to be followed during processing

type Stats

type Stats struct {
	ElapsedMs int64
	Files     map[Action][]string
}

Stats is the result of processing multiple files

func Files

func Files(options *Options, h fileHandler) (*Stats, error)

Files processes a group of files (in parallel) following the configuration defined in options

func NewStats

func NewStats() *Stats

NewStats creates a Stats struct with initialized Files

func (*Stats) AddOperation

func (s *Stats) AddOperation(operation *Operation)

AddOperation to stats

Jump to

Keyboard shortcuts

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