Skip to content

Commit

Permalink
requested changes per #334
Browse files Browse the repository at this point in the history
  • Loading branch information
sneak committed Dec 3, 2022
1 parent f25a261 commit 227541b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import "io"

// Flag is used by many of the framework generators
type Flag struct {
Embed bool
Minify bool
Hot bool
Noautolaunch bool
Embed bool
Minify bool
Hot bool
OpenBrowser bool

// Comes from *bud.Input
Stdin io.Reader
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *CLI) Run(ctx context.Context, args ...string) error {
cli.Flag("embed", "embed assets").Bool(&cmd.Flag.Embed).Default(false)
cli.Flag("hot", "hot reloading").Bool(&cmd.Flag.Hot).Default(true)
cli.Flag("minify", "minify assets").Bool(&cmd.Flag.Minify).Default(false)
cli.Flag("noautolaunch", "don't autolaunch browser").Bool(&cmd.Flag.Noautolaunch).Default(false)
cli.Flag("open", "open browser on dev server startup").Bool(&cmd.Flag.OpenBrowser).Default(false)
cli.Flag("listen", "address to listen to").String(&cmd.Listen).Default(":3000")
cli.Run(cmd.Run)
}
Expand Down
11 changes: 5 additions & 6 deletions internal/cli/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@ func (c *Command) Run(ctx context.Context) (err error) {
eg.Go(func() error { return appServer.Run(ctx) })
// Wait until either the hot or web server exits

// Launch browser unless we're told not to
if !c.Flag.Noautolaunch { // if not not autolaunch, i.e. if autolaunch
go func() {
time.Sleep(1 * time.Second)
_ = browser.OpenURL("http://" + webln.Addr().String())
}()
if !c.Flag.OpenBrowser {
err := browser.OpenURL("http://" + webln.Addr().String())
if err != nil {
return err
}
}

err = eg.Wait()
Expand Down

0 comments on commit 227541b

Please sign in to comment.