cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 31 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalCmds = NewCommands()

GlobalCmds is a global map of commands.

Functions

func Check added in v0.3.0

func Check(cfg *MainConfig) (int, error)

func DefaultCacheDir added in v0.3.0

func DefaultCacheDir() string

func FormatReport added in v0.3.0

func FormatReport(r *linter.Report) string

func Help added in v0.3.0

func Help(*MainConfig) (int, error)

func InitEmbeddedRules added in v0.3.0

func InitEmbeddedRules(p *rules.Parser, filter func(r rules.Rule) bool) ([]*rules.Set, error)

func LoadEmbeddedStubs added in v0.2.0

func LoadEmbeddedStubs(filenames []string) error

func LoadMisspellDicts added in v0.3.0

func LoadMisspellDicts(dicts []string) error

func Main

func Main(cfg *MainConfig)

Main is like Run(), but it calls os.Exit() and does not return.

func RegisterDefaultCommands added in v0.3.0

func RegisterDefaultCommands()

RegisterDefaultCommands registers default commands for NoVerify.

func Run added in v0.3.0

func Run(cfg *MainConfig) (int, error)

Run executes linter main function.

It is separate from linter so that you can insert your own hooks before running Run().

It returns a status code to be used for os.Exit() and initialization error (if any).

Optionally, non-nil config can be passed to customize function behavior.

Types

type Commands added in v0.3.0

type Commands struct {
	Commands map[string]*SubCommand
}

func NewCommands added in v0.3.0

func NewCommands() *Commands

func (*Commands) GetCommand added in v0.3.0

func (c *Commands) GetCommand(name string) (*SubCommand, bool)

func (*Commands) HelpPage added in v0.3.0

func (c *Commands) HelpPage() string

func (*Commands) OverrideCommand added in v0.3.0

func (c *Commands) OverrideCommand(command *SubCommand)

func (*Commands) OverrideCommands added in v0.3.0

func (c *Commands) OverrideCommands(commands *Commands)

func (*Commands) PrintHelpPage added in v0.3.0

func (c *Commands) PrintHelpPage()

func (*Commands) RegisterCommand added in v0.3.0

func (c *Commands) RegisterCommand(command *SubCommand)

func (*Commands) WriteHelpPage added in v0.3.0

func (c *Commands) WriteHelpPage(w io.Writer)

type InitEnvironment added in v0.3.0

type InitEnvironment struct {
	RuleSets []*rules.Set
}

InitEnvironment passes the state that may be required to finish custom linters initialization.

type MainConfig

type MainConfig struct {
	// AfterFlagParse is called right after flag.Parse() returned.
	// Can be used to examine flags that were bound prior to the Main() call.
	//
	// If nil, behaves as a no-op function.
	AfterFlagParse func(InitEnvironment)

	// BeforeReport acts as both an on-report action and a filter.
	//
	// If false is returned, the given report will not be reported.
	BeforeReport func(*linter.Report) bool

	LinterVersion string

	// OverriddenCommands is a list of new commands and
	// commands that override existing commands.
	OverriddenCommands *Commands
}

MainConfig describes optional main function config. All zero field values have some defined behavior.

type SubCommand added in v0.3.0

type SubCommand struct {
	Name        string
	Main        func(*MainConfig) (int, error)
	Description string
	Examples    []SubCommandExample
}

func (*SubCommand) String added in v0.3.0

func (s *SubCommand) String() string

type SubCommandExample added in v0.3.0

type SubCommandExample struct {
	Description string
	Line        string
}

Directories

Path Synopsis
Package embeddedrules Code generated by go-bindata.
Package embeddedrules Code generated by go-bindata.
Package stubs Code generated by go-bindata.
Package stubs Code generated by go-bindata.

Jump to

Keyboard shortcuts

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