Skip to content

Commit

Permalink
feat: add ftl dev --init-db flag (#1793)
Browse files Browse the repository at this point in the history
This spins up the container and initialises the database, then exits.
alecthomas authored Jun 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7184849 commit fc13221
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/ftl/cmd_dev.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package main
import (
"context"
"errors"
"fmt"
"time"

"golang.org/x/sync/errgroup"
@@ -23,6 +24,7 @@ type devCmd struct {
NoServe bool `help:"Do not start the FTL server." default:"false"`
Lsp bool `help:"Run the language server." default:"false"`
ServeCmd serveCmd `embed:""`
InitDB bool `help:"Initialize the database and exit." default:"false"`
languageServer *lsp.Server
}

@@ -43,6 +45,16 @@ func (d *devCmd) Run(ctx context.Context, projConfig projectconfig.Config) error
logger := log.FromContext(ctx)
return KillBackgroundServe(logger)
}

if d.InitDB {
dsn, err := d.ServeCmd.setupDB(ctx)
if err != nil {
return fmt.Errorf("failed to setup database: %w", err)
}
fmt.Println(dsn)
return nil
}

if !d.NoServe {
if d.ServeCmd.Stop {
err := d.ServeCmd.Run(ctx)

0 comments on commit fc13221

Please sign in to comment.