diff --git a/cli/commands/be.go b/cli/commands/be.go index d5e660103..e7b2fb1d7 100644 --- a/cli/commands/be.go +++ b/cli/commands/be.go @@ -14,12 +14,22 @@ func RunBackendCommand() *cli.Command { Name: "be", Usage: "Run the backend", Category: "Development", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "use-dev-dot-env", + Usage: "Use the development .env file", + Value: false, + Aliases: []string{"d"}, + }, + }, Action: func(c *cli.Context) error { if c.Args().Len() > 0 { return cli.Exit("Invalid arguments", 1) } - err := RunBE() + useDevDotEnv := c.Bool("use-dev-dot-env") + + err := RunBE(useDevDotEnv) if err != nil { return cli.Exit(err.Error(), 1) } @@ -31,8 +41,15 @@ func RunBackendCommand() *cli.Command { return &command } -func RunBE() error { - goCmd := exec.Command("go", "run", "main.go") +func RunBE(useDevDotEnv bool) error { + var goCmd *exec.Cmd + + if useDevDotEnv { + goCmd = exec.Command("go", "run", "main.go", "--use-dev-dot-env") + } else { + goCmd = exec.Command("go", "run", "main.go") + } + goCmd.Dir = BACKEND_DIR goCmd.Stdout = os.Stdout