Skip to content

Commit

Permalink
feat: add --replace flag to ftl init go (#851)
Browse files Browse the repository at this point in the history
This is mostly useful for local development on FTL itself, including
integration tests, where we need to replace the ftl import with local
ftl source.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
alecthomas and github-actions[bot] authored Jan 30, 2024
1 parent ef4976b commit 9eee959
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/ftl/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ type initCmd struct {
}

type initGoCmd struct {
Dir string `arg:"" help:"Directory to initialize the module in."`
Name string `arg:"" help:"Name of the FTL module to create underneath the base directory."`
Replace map[string]string `short:"r" help:"Replace a module import path with a local path in the initialised FTL module." placeholder:"OLD=NEW,..."`
Dir string `arg:"" help:"Directory to initialize the module in."`
Name string `arg:"" help:"Name of the FTL module to create underneath the base directory."`
}

func (i initGoCmd) Run(ctx context.Context, parent *initCmd) error {
Expand Down
2 changes: 1 addition & 1 deletion go-runtime/scaffolding/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This needs to exist so that the Go toolchain doesn't include this directory. Annoying.
module exclude

go 1.21.6
go 1.21.6
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ module ftl/{{ .Name }}

go 1.21

require github.com/TBD54566975/ftl latest
require github.com/TBD54566975/ftl latest

{{- range $old, $new := .Replace }}
replace {{ $old }} => {{ $new }}
{{- end }}

0 comments on commit 9eee959

Please sign in to comment.