Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 4b1510d

Browse files
committed
feat: add -o // --output flag to golangci-custom (#1)
> [!NOTE] > `golangci-lint` maintainer [refuses to consider this change](golangci#5369 (comment)). Confirmed the help output is as expected: ``` Build a version of golangci-lint with custom linters Usage: golangci-lint custom [flags] Flags: -o, --output string Path to output file Global Flags: --color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto") -h, --help Help for a command -v, --verbose Verbose output ```
1 parent a2ef9ee commit 4b1510d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pkg/commands/custom.go

+14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"path"
78

9+
"github.com/fatih/color"
810
"github.com/spf13/cobra"
911

1012
"github.com/golangci/golangci-lint/pkg/commands/internal"
@@ -13,6 +15,10 @@ import (
1315

1416
const envKeepTempFiles = "CUSTOM_GCL_KEEP_TEMP_FILES"
1517

18+
var (
19+
outputArgument = ""
20+
)
21+
1622
type customCommand struct {
1723
cmd *cobra.Command
1824

@@ -33,6 +39,8 @@ func newCustomCommand(logger logutils.Log) *customCommand {
3339
SilenceUsage: true,
3440
}
3541

42+
customCmd.Flags().StringVarP(&outputArgument, "output", "o", "", color.GreenString("Path to output file"))
43+
3644
c.cmd = customCmd
3745

3846
return c
@@ -44,6 +52,12 @@ func (c *customCommand) preRunE(_ *cobra.Command, _ []string) error {
4452
return err
4553
}
4654

55+
if outputArgument != "" {
56+
directory, name := path.Split(outputArgument)
57+
cfg.Destination = directory
58+
cfg.Name = name
59+
}
60+
4761
err = cfg.Validate()
4862
if err != nil {
4963
return err

0 commit comments

Comments
 (0)