Skip to content

Commit cfd0e74

Browse files
committed
Switch Authors to []any
and updated tests to use both strings and *mail.Address
1 parent 6d7ed03 commit cfd0e74

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

app.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"flag"
66
"fmt"
77
"io"
8-
"net/mail"
98
"os"
109
"path/filepath"
1110
"sort"
@@ -79,8 +78,8 @@ type App struct {
7978
OnUsageError OnUsageErrorFunc
8079
// Execute this function when an invalid flag is accessed from the context
8180
InvalidFlagAccessHandler InvalidFlagAccessFunc
82-
// List of all authors who contributed
83-
Authors []*mail.Address
81+
// List of all authors who contributed (string or fmt.Stringer)
82+
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
8483
// Copyright of the binary if any
8584
Copyright string
8685
// Reader reader to write input to (useful for tests)

app_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func ExampleApp_Run() {
4646
return nil
4747
},
4848
UsageText: "app [first_arg] [second_arg]",
49-
Authors: []*mail.Address{{Name: "Oliver Allen", Address: "[email protected]"}},
49+
Authors: []any{&mail.Address{Name: "Oliver Allen", Address: "[email protected]"}, "[email protected]"},
5050
}
5151

5252
app.Run(os.Args)
@@ -101,9 +101,9 @@ func ExampleApp_Run_appHelp() {
101101
Name: "greet",
102102
Version: "0.1.0",
103103
Description: "This is how we describe greet the app",
104-
Authors: []*mail.Address{
105-
{Name: "Harrison", Address: "[email protected]"},
106-
{Name: "Oliver Allen", Address: "[email protected]"},
104+
Authors: []any{
105+
&mail.Address{Name: "Harrison", Address: "harrison@lolwut.example.com"},
106+
"Oliver Allen <oliver@toyshop.example.com>",
107107
},
108108
Flags: []Flag{
109109
&StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
@@ -136,8 +136,8 @@ func ExampleApp_Run_appHelp() {
136136
// This is how we describe greet the app
137137
//
138138
// AUTHORS:
139-
// "Harrison" <[email protected]>
140-
// "Oliver Allen" <[email protected]>
139+
// "Harrison" <harrison@lolwut.example.com>
140+
// Oliver Allen <oliver@toyshop.example.com>
141141
//
142142
// COMMANDS:
143143
// describeit, d use it to see a description

docs_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package cli
55

66
import (
77
"errors"
8-
"net/mail"
98
"testing"
109
)
1110

@@ -50,7 +49,7 @@ func TestToMarkdownNoCommands(t *testing.T) {
5049
func TestToMarkdownNoAuthors(t *testing.T) {
5150
// Given
5251
app := testApp()
53-
app.Authors = []*mail.Address{}
52+
app.Authors = []any{}
5453

5554
// When
5655
res, err := app.ToMarkdown()

fish_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ Should be a part of the same code block
128128
app.UsageText = "app [first_arg] [second_arg]"
129129
app.Description = `Description of the application.`
130130
app.Usage = "Some app"
131-
app.Authors = []*mail.Address{
132-
{Name: "Harrison", Address: "[email protected]"},
133-
{Name: "Oliver Allen", Address: "[email protected]"},
131+
app.Authors = []any{
132+
"Harrison <harrison@lolwut.example.com>",
133+
&mail.Address{Name: "Oliver Allen", Address: "[email protected]"},
134134
}
135135
return app
136136
}

godoc-current.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ type App struct {
293293
OnUsageError OnUsageErrorFunc
294294
// Execute this function when an invalid flag is accessed from the context
295295
InvalidFlagAccessHandler InvalidFlagAccessFunc
296-
// List of all authors who contributed
297-
Authors []*mail.Address
296+
// List of all authors who contributed (string or fmt.Stringer)
297+
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
298298
// Copyright of the binary if any
299299
Copyright string
300300
// Reader reader to write input to (useful for tests)

testdata/godoc-v3.x.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ type App struct {
293293
OnUsageError OnUsageErrorFunc
294294
// Execute this function when an invalid flag is accessed from the context
295295
InvalidFlagAccessHandler InvalidFlagAccessFunc
296-
// List of all authors who contributed
297-
Authors []*mail.Address
296+
// List of all authors who contributed (string or fmt.Stringer)
297+
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
298298
// Copyright of the binary if any
299299
Copyright string
300300
// Reader reader to write input to (useful for tests)

0 commit comments

Comments
 (0)