Skip to content

Commit

Permalink
feat: use GOFILE if set
Browse files Browse the repository at this point in the history
I've updated the `--source-file` parameter to use the `GOFILE` env var by default. This means that the file name doesn't need to be specified in the `go:generate` commands.
  • Loading branch information
adamconnelly committed Nov 28, 2023
1 parent 37a8d90 commit a8eb895
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go install github.com/adamconnelly/kelpie/cmd/kelpie@latest
Add a `go:generate` marker to the interface you want to mock:

```go
//go:generate kelpie generate --source-file <filename>.go --interfaces EmailService
//go:generate kelpie generate --interfaces EmailService
type EmailService interface {
Send(sender, recipient, body string) (cost float64, err error)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kelpie/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var mockTemplate string

type GenerateCmd struct {
SourceFile string `short:"s" required:"" help:"The Go source file containing the interface to mock."`
SourceFile string `short:"s" required:"" env:"GOFILE" help:"The Go source file containing the interface to mock."`
Interfaces []string `short:"i" required:"" help:"The names of the interfaces to mock."`
OutputDir string `short:"o" required:"" default:"mocks" help:"The directory to write the mock out to."`
}
Expand Down
2 changes: 1 addition & 1 deletion examples/argument_matching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/suite"
)

//go:generate go run ../cmd/kelpie generate --source-file argument_matching_test.go --interfaces Maths
//go:generate go run ../cmd/kelpie generate --interfaces Maths
type Maths interface {
Add(a, b int) int
ParseInt(input string) (int, error)
Expand Down
2 changes: 1 addition & 1 deletion examples/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/suite"
)

//go:generate go run ../cmd/kelpie generate --source-file result_test.go --interfaces AccountService
//go:generate go run ../cmd/kelpie generate --interfaces AccountService
type AccountService interface {
SendActivationEmail(emailAddress string) bool
DisableAccount(id uint)
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type ResultDefinition struct {
Type string
}

//go:generate go run ../cmd/kelpie generate --source-file parser.go --interfaces InterfaceFilter
//go:generate go run ../cmd/kelpie generate --interfaces InterfaceFilter
type InterfaceFilter interface {
// Include indicates that the specified interface should be included in the set of interfaces
// to generate.
Expand Down

0 comments on commit a8eb895

Please sign in to comment.