From 1b6f0069d4a7b81a9f39862c68c71bc3fd486dd4 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 19 Mar 2024 21:49:18 +0100 Subject: [PATCH] dev: silence help on some commands usage on error (#4542) --- pkg/commands/custom.go | 11 ++++++----- pkg/commands/linters.go | 1 + pkg/commands/run.go | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/commands/custom.go b/pkg/commands/custom.go index dd7b1bb2..1bc9f901 100644 --- a/pkg/commands/custom.go +++ b/pkg/commands/custom.go @@ -25,11 +25,12 @@ func newCustomCommand(logger logutils.Log) *customCommand { c := &customCommand{log: logger} customCmd := &cobra.Command{ - Use: "custom", - Short: "Build a version of golangci-lint with custom linters", - Args: cobra.NoArgs, - PreRunE: c.preRunE, - RunE: c.runE, + Use: "custom", + Short: "Build a version of golangci-lint with custom linters", + Args: cobra.NoArgs, + PreRunE: c.preRunE, + RunE: c.runE, + SilenceUsage: true, } c.cmd = customCmd diff --git a/pkg/commands/linters.go b/pkg/commands/linters.go index 08394770..61ed0f22 100644 --- a/pkg/commands/linters.go +++ b/pkg/commands/linters.go @@ -44,6 +44,7 @@ func newLintersCommand(logger logutils.Log) *lintersCommand { ValidArgsFunction: cobra.NoFileCompletions, RunE: c.execute, PreRunE: c.preRunE, + SilenceUsage: true, } fs := lintersCmd.Flags() diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 48d4ef8c..8ed8c5ee 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -118,6 +118,7 @@ func newRunCommand(logger logutils.Log, info BuildInfo) *runCommand { PostRun: c.postRun, PersistentPreRunE: c.persistentPreRunE, PersistentPostRunE: c.persistentPostRunE, + SilenceUsage: true, } runCmd.SetOut(logutils.StdOut) // use custom output to properly color it in Windows terminals