@@ -28,11 +28,11 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
28
28
color .GreenString ("Enable only fast linters from enabled linters set (first run won't be fast)" ))
29
29
30
30
internal .AddHackedStringSliceP (fs , "presets" , "p" ,
31
- color . GreenString ( fmt . Sprintf ( "Enable presets (%s) of linters. \n " +
32
- "Run 'golangci-lint help linters' to see them.\n " +
31
+ formatList ( "Enable presets of linters:" , lintersdb . AllPresets (),
32
+ "Run 'golangci-lint help linters' to see them." ,
33
33
"This option implies option --disable-all" ,
34
- strings . Join ( lintersdb . AllPresets (), "|" ),
35
- )) )
34
+ ),
35
+ )
36
36
37
37
fs .StringSlice ("enable-only" , nil ,
38
38
color .GreenString ("Override linters configuration section to only run the specific linter(s)" )) // Flags only.
@@ -57,7 +57,7 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
57
57
internal .AddDeprecatedHackedStringSlice (fs , "skip-files" , color .GreenString ("Regexps of files to skip" ))
58
58
internal .AddDeprecatedHackedStringSlice (fs , "skip-dirs" , color .GreenString ("Regexps of directories to skip" ))
59
59
internal .AddDeprecatedFlagAndBind (v , fs , fs .Bool , "skip-dirs-use-default" , "run.skip-dirs-use-default" , true ,
60
- getDefaultDirectoryExcludeHelp ( ))
60
+ formatList ( "Use or not use default excluded directories:" , processors . StdExcludeDirRegexps ))
61
61
62
62
const allowParallelDesc = "Allow multiple parallel golangci-lint instances running.\n " +
63
63
"If false (default) - golangci-lint acquires file lock on start."
@@ -70,7 +70,7 @@ func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
70
70
71
71
func setupOutputFlagSet (v * viper.Viper , fs * pflag.FlagSet ) {
72
72
internal .AddFlagAndBind (v , fs , fs .String , "out-format" , "output.formats" , config .OutFormatColoredLineNumber ,
73
- color . GreenString ( fmt . Sprintf ( "Formats of output: %s " , strings . Join ( config .AllOutputFormats , "|" )) ))
73
+ formatList ( "Formats of output:" , config .AllOutputFormats ))
74
74
internal .AddFlagAndBind (v , fs , fs .Bool , "print-issued-lines" , "output.print-issued-lines" , true ,
75
75
color .GreenString ("Print lines of code with issue" ))
76
76
internal .AddFlagAndBind (v , fs , fs .Bool , "print-linter-name" , "output.print-linter-name" , true ,
@@ -102,7 +102,7 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
102
102
internal .AddHackedStringSlice (fs , "exclude-files" , color .GreenString ("Regexps of files to exclude" ))
103
103
internal .AddHackedStringSlice (fs , "exclude-dirs" , color .GreenString ("Regexps of directories to exclude" ))
104
104
internal .AddFlagAndBind (v , fs , fs .Bool , "exclude-dirs-use-default" , "issues.exclude-dirs-use-default" , true ,
105
- getDefaultDirectoryExcludeHelp ( ))
105
+ formatList ( "Use or not use default excluded directories:" , processors . StdExcludeDirRegexps ))
106
106
107
107
internal .AddFlagAndBind (v , fs , fs .String , "exclude-generated" , "issues.exclude-generated" , processors .AutogeneratedModeLax ,
108
108
color .GreenString ("Mode of the generated files analysis" ))
@@ -124,6 +124,23 @@ func setupIssuesFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
124
124
color .GreenString ("Fix found issues (if it's supported by the linter)" ))
125
125
}
126
126
127
+ func formatList (head string , items []string , foot ... string ) string {
128
+ parts := []string {color .GreenString (head )}
129
+ for _ , p := range items {
130
+ parts = append (parts , fmt .Sprintf (" - %s" , color .YellowString (p )))
131
+ }
132
+
133
+ for _ , s := range foot {
134
+ parts = append (parts , color .GreenString (s ))
135
+ }
136
+
137
+ if len (foot ) == 0 {
138
+ parts = append (parts , "" )
139
+ }
140
+
141
+ return strings .Join (parts , "\n " )
142
+ }
143
+
127
144
func getDefaultIssueExcludeHelp () string {
128
145
parts := []string {color .GreenString ("Use or not use default excludes:" )}
129
146
@@ -136,12 +153,3 @@ func getDefaultIssueExcludeHelp() string {
136
153
137
154
return strings .Join (parts , "\n " )
138
155
}
139
-
140
- func getDefaultDirectoryExcludeHelp () string {
141
- parts := []string {color .GreenString ("Use or not use default excluded directories:" )}
142
- for _ , dir := range processors .StdExcludeDirRegexps {
143
- parts = append (parts , fmt .Sprintf (" - %s" , color .YellowString (dir )))
144
- }
145
- parts = append (parts , "" )
146
- return strings .Join (parts , "\n " )
147
- }
0 commit comments