55 "log"
66 "os"
77
8+ "github.com/fatih/color"
89 "github.com/spf13/cobra"
910
1011 "github.com/golangci/golangci-lint/v2/pkg/commands/internal"
@@ -13,11 +14,19 @@ import (
1314
1415const envKeepTempFiles = "CUSTOM_GCL_KEEP_TEMP_FILES"
1516
17+ type customOptions struct {
18+ version string
19+ name string
20+ destination string
21+ }
22+
1623type customCommand struct {
1724 cmd * cobra.Command
1825
1926 cfg * internal.Configuration
2027
28+ opts customOptions
29+
2130 log logutils.Log
2231}
2332
@@ -33,6 +42,13 @@ func newCustomCommand(logger logutils.Log) *customCommand {
3342 SilenceUsage : true ,
3443 }
3544
45+ flagSet := customCmd .PersistentFlags ()
46+ flagSet .SortFlags = false // sort them as they are defined here
47+
48+ flagSet .StringVar (& c .opts .version , "version" , "" , color .GreenString ("The golangci-lint version used to build the custom binary" ))
49+ flagSet .StringVar (& c .opts .name , "name" , "" , color .GreenString ("The name of the custom binary" ))
50+ flagSet .StringVar (& c .opts .destination , "destination" , "" , color .GreenString ("The directory path used to store the custom binary" ))
51+
3652 c .cmd = customCmd
3753
3854 return c
@@ -44,6 +60,18 @@ func (c *customCommand) preRunE(_ *cobra.Command, _ []string) error {
4460 return err
4561 }
4662
63+ if c .opts .version != "" {
64+ cfg .Version = c .opts .version
65+ }
66+
67+ if c .opts .name != "" {
68+ cfg .Name = c .opts .name
69+ }
70+
71+ if c .opts .destination != "" {
72+ cfg .Destination = c .opts .destination
73+ }
74+
4775 err = cfg .Validate ()
4876 if err != nil {
4977 return err
0 commit comments