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
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ formatters:
enable:
- gofumpt
- goimports
- golines

settings:
gofumpt:
extra-rules: true

golines:
max-len: 140
shorten-comments: true
reformat-tags: true

linters:
default: all
disable:
Expand Down
5 changes: 3 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ tasks:
desc: Run go fmt on all source files
sources:
- "**/*.go"
- .golangci.yml
cmds:
- go fmt ./...
- golangci-lint fmt ./...

test:
desc: Run the test suite
sources:
- "**/*.go"
- testdata/**/*.txt
- "**/testdata/**/*"
- go.mod
- go.sum
cmds:
Expand Down
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ func writeSubcommands(cmd *Command, s *strings.Builder) error {

s.WriteString(colour.Title("Commands"))
s.WriteByte(':')
s.WriteByte('\n')
s.WriteString("\n\n")

tab := table.New(s)
for _, subcommand := range cmd.subcommands {
Expand Down
5 changes: 5 additions & 0 deletions internal/flag/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ func TestFlagSet(t *testing.T) {

err = flag.AddToSet(set, f)
test.Err(t, err)

if err != nil {
test.Equal(t, err.Error(), "cannot add flag to a nil set")
}
Expand All @@ -961,6 +962,7 @@ func TestFlagSet(t *testing.T) {
test: func(t *testing.T, set *flag.Set) {
err := set.Parse([]string{"args", "here", "doesn't", "matter"})
test.Err(t, err)

if err != nil {
test.Equal(t, err.Error(), "Parse called on a nil set")
}
Expand Down Expand Up @@ -990,6 +992,7 @@ func TestFlagSet(t *testing.T) {
// Add the same flag again
err = flag.AddToSet(set, f)
test.Err(t, err)

if err != nil {
test.Equal(t, err.Error(), `flag "count" already defined`)
}
Expand All @@ -1013,6 +1016,7 @@ func TestFlagSet(t *testing.T) {
// Add the different flag with the same na,e
err = flag.AddToSet(set, f2)
test.Err(t, err)

if err != nil {
test.Equal(t, err.Error(), `flag "count" already defined`)
}
Expand All @@ -1036,6 +1040,7 @@ func TestFlagSet(t *testing.T) {
// Add the different flag with the same na,e
err = flag.AddToSet(set, f2)
test.Err(t, err)

if err != nil {
test.Equal(t, err.Error(), `shorthand "c" already in use for flag "count"`)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func New(w io.Writer) Table {
}

// Row adds a row to the [Table].
//
//nolint:goprintffuncname // I like it this way
func (t Table) Row(format string, a ...any) {
fmt.Fprintf(t.tw, format, a...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A longer, probably multiline description
Usage: test [OPTIONS] COMMAND

Commands:

sub1 Do one thing
sub2 Do another thing
very-long-subcommand Wow so long
Expand Down
1 change: 1 addition & 0 deletions testdata/snapshots/TestHelp/with_subcommands.snap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A longer, probably multiline description
Usage: test [OPTIONS] COMMAND

Commands:

sub1 Do one thing
sub2 Do another thing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A longer, probably multiline description
Usage: test [OPTIONS] COMMAND

Commands:

sub1 Do one thing
sub2 Do another thing

Expand Down
Loading