Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ linters:
- unparam # gopls is better and more subtle
- varnamelen # Lots of false positives of things that are fine
- wrapcheck # Not every error must be wrapped
- wsl # Very aggressive, some of this I like but tend to do anyway
- wsl_v5 # Very aggressive, some of this I like but tend to do anyway
- wsl # Deprecated

exclusions:
presets:
# See https://golangci-lint.run/usage/false-positives/#exclusion-presets
- comments # Revive in particular has lots of false positives
- std-error-handling
- common-false-positives
rules:
Expand Down Expand Up @@ -155,10 +153,7 @@ linters:
disabled: true # predeclared does this

- name: unhandled-error
arguments:
- fmt\.(Fp|P)rint(ln|f)?
- strings.Builder.Write(String|Byte)?
- bytes.Buffer.Write(String|Byte)?
disabled: true # errcheck handles this

- name: flag-parameter
disabled: true # As far as I can work out this just doesn't like bools
Expand Down
5 changes: 4 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func New(name string, options ...Option) (*Command, error) {
errs = errors.Join(errs, err) // nil errors are discarded in join

err = Flag(&cfg.versionCalled, "version", 'V', false, "Show version info for "+name).apply(&cfg)
errs = errors.Join(errs, err)

errs = errors.Join(errs, err)
if errs != nil {
return nil, errs
}
Expand Down Expand Up @@ -472,7 +472,9 @@ func stripFlags(cmd *Command, args []string) []string {
if len(args) <= 1 {
return argsWithoutFlags
}

args = args[1:]

continue

case arg != "" && !strings.HasPrefix(arg, "-"):
Expand Down Expand Up @@ -669,6 +671,7 @@ func writeSubcommands(cmd *Command, s *strings.Builder) error {
} else {
s.WriteString("\n\n")
}

s.WriteString(colour.Title("Commands"))
s.WriteByte(':')
s.WriteByte('\n')
Expand Down
1 change: 1 addition & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ func TestCommandNoRunNoSub(t *testing.T) {

func TestExecuteNilCommand(t *testing.T) {
var cmd *cli.Command

err := cmd.Execute()
test.Err(t, err)

Expand Down
5 changes: 3 additions & 2 deletions internal/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const (
)

const (
boolTrue = "true"
boolFalse = "false"
boolTrue = "true"
)

// NoShortHand should be passed as the "short" argument to [New] if the desired flag
Expand Down Expand Up @@ -891,6 +890,7 @@ func formatStringSlice(slice []string) string {
length := len(slice)
s := &strings.Builder{}
s.WriteByte('[')

for index, elem := range slice {
s.WriteString(strconv.Quote(elem))
// Write commas and a space on every element other than the last one
Expand All @@ -899,6 +899,7 @@ func formatStringSlice(slice []string) string {
s.WriteByte(' ')
}
}

s.WriteByte(']')

return s.String()
Expand Down
Loading
Loading