change flag to string

This commit is contained in:
Alexander Wang 2023-03-18 00:48:18 -07:00
parent dc079c676d
commit efc85915c6
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 4 additions and 7 deletions

View file

@ -81,7 +81,7 @@ Renders the diagram to look like it was sketched by hand
Pixels padded around the rendered diagram
.Ns .
.It Fl -browser Ar true
Open the browser and go to the address that watch streams updates to
Browser executable that watch opens. Setting to 0 opens no browser
.Ns .
.It Fl l , -layout Ar dagre
Set the diagram layout engine to the passed string. For a list of available options, run

View file

@ -83,10 +83,7 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
if err != nil {
return err
}
browserFlag, err := ms.Opts.Bool("BROWSER", "browser", "", true, "open the browser and go to the address that watch streams updates to")
if err != nil {
return err
}
browserFlag := ms.Opts.String("BROWSER", "browser", "", "", "browser executable that watch opens. Setting to 0 opens no browser.")
ps, err := d2plugin.ListPlugins(ctx)
if err != nil {
@ -130,8 +127,8 @@ func Run(ctx context.Context, ms *xmain.State) (err error) {
if *debugFlag {
ms.Env.Setenv("DEBUG", "1")
}
if !*browserFlag {
ms.Env.Setenv("BROWSER", "0")
if *browserFlag != "" {
ms.Env.Setenv("BROWSER", *browserFlag)
}
var inputPath string