Skip to content

Commit

Permalink
Fix: Update CLI to allow use of --use-dev-dot-env (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored Feb 25, 2024
1 parent 429d935 commit d04cb71
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cli/commands/be.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down

0 comments on commit d04cb71

Please sign in to comment.