Skip to content

Commit

Permalink
Switch Authors to []any
Browse files Browse the repository at this point in the history
and updated tests to use both strings and *mail.Address
  • Loading branch information
meatballhat committed Jan 1, 2023
1 parent 6d7ed03 commit cfd0e74
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
5 changes: 2 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"net/mail"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -79,8 +78,8 @@ type App struct {
OnUsageError OnUsageErrorFunc
// Execute this function when an invalid flag is accessed from the context
InvalidFlagAccessHandler InvalidFlagAccessFunc
// List of all authors who contributed
Authors []*mail.Address
// List of all authors who contributed (string or fmt.Stringer)
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
// Copyright of the binary if any
Copyright string
// Reader reader to write input to (useful for tests)
Expand Down
12 changes: 6 additions & 6 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ExampleApp_Run() {
return nil
},
UsageText: "app [first_arg] [second_arg]",
Authors: []*mail.Address{{Name: "Oliver Allen", Address: "oliver@toyshop.example.com"}},
Authors: []any{&mail.Address{Name: "Oliver Allen", Address: "oliver@toyshop.example.com"}, "gruffalo@soup-world.example.org"},
}

app.Run(os.Args)
Expand Down Expand Up @@ -101,9 +101,9 @@ func ExampleApp_Run_appHelp() {
Name: "greet",
Version: "0.1.0",
Description: "This is how we describe greet the app",
Authors: []*mail.Address{
{Name: "Harrison", Address: "harrison@lolwut.com"},
{Name: "Oliver Allen", Address: "oliver@toyshop.com"},
Authors: []any{
&mail.Address{Name: "Harrison", Address: "harrison@lolwut.example.com"},
"Oliver Allen <oliver@toyshop.example.com>",
},
Flags: []Flag{
&StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
Expand Down Expand Up @@ -136,8 +136,8 @@ func ExampleApp_Run_appHelp() {
// This is how we describe greet the app
//
// AUTHORS:
// "Harrison" <harrison@lolwut.com>
// "Oliver Allen" <oliver@toyshop.com>
// "Harrison" <harrison@lolwut.example.com>
// Oliver Allen <oliver@toyshop.example.com>
//
// COMMANDS:
// describeit, d use it to see a description
Expand Down
3 changes: 1 addition & 2 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cli

import (
"errors"
"net/mail"
"testing"
)

Expand Down Expand Up @@ -50,7 +49,7 @@ func TestToMarkdownNoCommands(t *testing.T) {
func TestToMarkdownNoAuthors(t *testing.T) {
// Given
app := testApp()
app.Authors = []*mail.Address{}
app.Authors = []any{}

// When
res, err := app.ToMarkdown()
Expand Down
6 changes: 3 additions & 3 deletions fish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ Should be a part of the same code block
app.UsageText = "app [first_arg] [second_arg]"
app.Description = `Description of the application.`
app.Usage = "Some app"
app.Authors = []*mail.Address{
{Name: "Harrison", Address: "harrison@lolwut.com"},
{Name: "Oliver Allen", Address: "oliver@toyshop.com"},
app.Authors = []any{
"Harrison <harrison@lolwut.example.com>",
&mail.Address{Name: "Oliver Allen", Address: "oliver@toyshop.com"},
}
return app
}
Expand Down
4 changes: 2 additions & 2 deletions godoc-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ type App struct {
OnUsageError OnUsageErrorFunc
// Execute this function when an invalid flag is accessed from the context
InvalidFlagAccessHandler InvalidFlagAccessFunc
// List of all authors who contributed
Authors []*mail.Address
// List of all authors who contributed (string or fmt.Stringer)
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
// Copyright of the binary if any
Copyright string
// Reader reader to write input to (useful for tests)
Expand Down
4 changes: 2 additions & 2 deletions testdata/godoc-v3.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ type App struct {
OnUsageError OnUsageErrorFunc
// Execute this function when an invalid flag is accessed from the context
InvalidFlagAccessHandler InvalidFlagAccessFunc
// List of all authors who contributed
Authors []*mail.Address
// List of all authors who contributed (string or fmt.Stringer)
Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
// Copyright of the binary if any
Copyright string
// Reader reader to write input to (useful for tests)
Expand Down

0 comments on commit cfd0e74

Please sign in to comment.