@@ -27,7 +27,12 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
27
27
internal .AddFlagAndBind (v , fs , fs .Bool , "fast" , "linters.fast" , false ,
28
28
color .GreenString ("Enable only fast linters from enabled linters set (first run won't be fast)" ))
29
29
30
- internal .AddHackedStringSliceP (fs , "presets" , "p" , getPresetsHelp ())
30
+ internal .AddHackedStringSliceP (fs , "presets" , "p" ,
31
+ formatList ("Enable presets of linters:" , lintersdb .AllPresets (),
32
+ "Run 'golangci-lint help linters' to see them." ,
33
+ "This option implies option --disable-all" ,
34
+ ),
35
+ )
31
36
32
37
fs .StringSlice ("enable-only" , nil ,
33
38
color .GreenString ("Override linters configuration section to only run the specific linter(s)" )) // Flags only.
@@ -51,7 +56,7 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
51
56
internal .AddDeprecatedHackedStringSlice (fs , "skip-files" , color .GreenString ("Regexps of files to skip" ))
52
57
internal .AddDeprecatedHackedStringSlice (fs , "skip-dirs" , color .GreenString ("Regexps of directories to skip" ))
53
58
internal .AddDeprecatedFlagAndBind (v , fs , fs .Bool , "skip-dirs-use-default" , "run.skip-dirs-use-default" , true ,
54
- getDefaultDirectoryExcludeHelp ( ))
59
+ formatList ( "Use or not use default excluded directories:" , processors . StdExcludeDirRegexps ))
55
60
56
61
const allowParallelDesc = "Allow multiple parallel golangci-lint instances running.\n " +
57
62
"If false (default) - golangci-lint acquires file lock on start."
@@ -63,7 +68,8 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
63
68
}
64
69
65
70
func setupOutputFlagSet (v * viper.Viper , fs * pflag.FlagSet ) {
66
- internal .AddFlagAndBind (v , fs , fs .String , "out-format" , "output.formats" , config .OutFormatColoredLineNumber , getOutFormatHelp ())
71
+ internal .AddFlagAndBind (v , fs , fs .String , "out-format" , "output.formats" , config .OutFormatColoredLineNumber ,
72
+ formatList ("Formats of output:" , config .AllOutputFormats ))
67
73
internal .AddFlagAndBind (v , fs , fs .Bool , "print-issued-lines" , "output.print-issued-lines" , true ,
68
74
color .GreenString ("Print lines of code with issue" ))
69
75
internal .AddFlagAndBind (v , fs , fs .Bool , "print-linter-name" , "output.print-linter-name" , true ,
@@ -95,7 +101,7 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
95
101
internal .AddHackedStringSlice (fs , "exclude-files" , color .GreenString ("Regexps of files to exclude" ))
96
102
internal .AddHackedStringSlice (fs , "exclude-dirs" , color .GreenString ("Regexps of directories to exclude" ))
97
103
internal .AddFlagAndBind (v , fs , fs .Bool , "exclude-dirs-use-default" , "issues.exclude-dirs-use-default" , true ,
98
- getDefaultDirectoryExcludeHelp ( ))
104
+ formatList ( "Use or not use default excluded directories:" , processors . StdExcludeDirRegexps ))
99
105
100
106
internal .AddFlagAndBind (v , fs , fs .String , "exclude-generated" , "issues.exclude-generated" , processors .AutogeneratedModeLax ,
101
107
color .GreenString ("Mode of the generated files analysis" ))
@@ -117,22 +123,20 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
117
123
color .GreenString ("Fix found issues (if it's supported by the linter)" ))
118
124
}
119
125
120
- func getPresetsHelp ( ) string {
121
- parts := []string {color .GreenString ("Enable presets of linters:" )}
122
- for _ , p := range lintersdb . AllPresets () {
126
+ func formatList ( head string , items [] string , foot ... string ) string {
127
+ parts := []string {color .GreenString (head )}
128
+ for _ , p := range items {
123
129
parts = append (parts , fmt .Sprintf (" - %s" , color .YellowString (p )))
124
130
}
125
- parts = append (parts , color .GreenString ("Run 'golangci-lint help linters' to see them." ),
126
- color .GreenString ("This option implies option --disable-all" ))
127
- return strings .Join (parts , "\n " )
128
- }
129
131
130
- func getOutFormatHelp () string {
131
- parts := []string {color .GreenString ("Formats of output:" )}
132
- for _ , f := range config .AllOutputFormats {
133
- parts = append (parts , fmt .Sprintf (" - %s" , color .YellowString (f )))
132
+ for _ , s := range foot {
133
+ parts = append (parts , color .GreenString (s ))
134
134
}
135
- parts = append (parts , "" )
135
+
136
+ if len (foot ) == 0 {
137
+ parts = append (parts , "" )
138
+ }
139
+
136
140
return strings .Join (parts , "\n " )
137
141
}
138
142
@@ -148,12 +152,3 @@ func getDefaultIssueExcludeHelp() string {
148
152
149
153
return strings .Join (parts , "\n " )
150
154
}
151
-
152
- func getDefaultDirectoryExcludeHelp () string {
153
- parts := []string {color .GreenString ("Use or not use default excluded directories:" )}
154
- for _ , dir := range processors .StdExcludeDirRegexps {
155
- parts = append (parts , fmt .Sprintf (" - %s" , color .YellowString (dir )))
156
- }
157
- parts = append (parts , "" )
158
- return strings .Join (parts , "\n " )
159
- }
0 commit comments