Documentation
¶
Index ¶
- Variables
- func Check(cfg *MainConfig) (int, error)
- func DefaultCacheDir() string
- func FormatReport(r *linter.Report) string
- func Help(*MainConfig) (int, error)
- func InitEmbeddedRules(p *rules.Parser, filter func(r rules.Rule) bool) ([]*rules.Set, error)
- func LoadEmbeddedStubs(filenames []string) error
- func LoadMisspellDicts(dicts []string) error
- func Main(cfg *MainConfig)
- func RegisterDefaultCommands()
- func Run(cfg *MainConfig) (int, error)
- type Commands
- func (c *Commands) GetCommand(name string) (*SubCommand, bool)
- func (c *Commands) HelpPage() string
- func (c *Commands) OverrideCommand(command *SubCommand)
- func (c *Commands) OverrideCommands(commands *Commands)
- func (c *Commands) PrintHelpPage()
- func (c *Commands) RegisterCommand(command *SubCommand)
- func (c *Commands) WriteHelpPage(w io.Writer)
- type InitEnvironment
- type MainConfig
- type SubCommand
- type SubCommandExample
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 Help ¶ added in v0.3.0
func Help(*MainConfig) (int, error)
func InitEmbeddedRules ¶ added in v0.3.0
func LoadEmbeddedStubs ¶ added in v0.2.0
func LoadMisspellDicts ¶ added in v0.3.0
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) OverrideCommand ¶ added in v0.3.0
func (c *Commands) OverrideCommand(command *SubCommand)
func (*Commands) OverrideCommands ¶ added in v0.3.0
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
type InitEnvironment ¶ added in v0.3.0
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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.