github.com/ferretdb/golangci-lint@v1.10.1/pkg/commands/executor.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/golangci/golangci-lint/pkg/config"
     5  	"github.com/golangci/golangci-lint/pkg/logutils"
     6  	"github.com/golangci/golangci-lint/pkg/report"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  type Executor struct {
    11  	rootCmd *cobra.Command
    12  
    13  	cfg *config.Config
    14  
    15  	exitCode int
    16  
    17  	version, commit, date string
    18  
    19  	log logutils.Log
    20  
    21  	reportData report.Data
    22  }
    23  
    24  func NewExecutor(version, commit, date string) *Executor {
    25  	e := &Executor{
    26  		cfg:     config.NewDefault(),
    27  		version: version,
    28  		commit:  commit,
    29  		date:    date,
    30  	}
    31  
    32  	e.log = report.NewLogWrapper(logutils.NewStderrLog(""), &e.reportData)
    33  
    34  	e.initRoot()
    35  	e.initRun()
    36  	e.initHelp()
    37  	e.initLinters()
    38  
    39  	return e
    40  }
    41  
    42  func (e Executor) Execute() error {
    43  	return e.rootCmd.Execute()
    44  }