feat(desktop): pass instance id as flag or environment variable

This commit is contained in:
wpetit 2024-01-12 17:09:19 +01:00
parent c53a566fe7
commit 9884855e3c
4 changed files with 22 additions and 9 deletions

View File

@ -1 +1,2 @@
ARCAST_DESKTOP_ADDITIONAL_CHROME_ARGS= ARCAST_DESKTOP_ADDITIONAL_CHROME_ARGS=
ARCAST_DESKTOP_INSTANCE_ID=

View File

@ -9,6 +9,6 @@ func main() {
command.Main( command.Main(
"arcast", "arcast",
"Arcast desktop player", "Arcast desktop player",
player.Root(), player.Root().Subcommands...,
) )
} }

View File

@ -21,13 +21,20 @@ func Run() *cli.Command {
EnvVars: []string{"ARCAST_DESKTOP_ADDITIONAL_CHROME_ARGS"}, EnvVars: []string{"ARCAST_DESKTOP_ADDITIONAL_CHROME_ARGS"},
Value: cli.NewStringSlice("incognito"), Value: cli.NewStringSlice("incognito"),
}, },
&cli.IntFlag{ &cli.StringFlag{
Name: "window-height", Name: "instance-id",
Value: defaults.Height, EnvVars: []string{"ARCAST_DESKTOP_INSTANCE_ID"},
Value: "",
}, },
&cli.IntFlag{ &cli.IntFlag{
Name: "window-width", Name: "window-height",
Value: defaults.Width, EnvVars: []string{"ARCAST_DESKTOP_WINDOW_HEIGHT"},
Value: defaults.Height,
},
&cli.IntFlag{
Name: "window-width",
EnvVars: []string{"ARCAST_DESKTOP_WINDOW_WIDTH"},
Value: defaults.Width,
}, },
}, },
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
@ -57,7 +64,12 @@ func Run() *cli.Command {
} }
}() }()
server := server.New(browser) instanceID := ctx.String("instance-id")
if instanceID == "" {
instanceID = server.NewRandomInstanceID()
}
server := server.New(browser, server.WithInstanceID(instanceID))
if err := server.Start(); err != nil { if err := server.Start(); err != nil {
return errors.Wrap(err, "could not start server") return errors.Wrap(err, "could not start server")

View File

@ -4,5 +4,5 @@ modd.conf
.env { .env {
prep: make build-client prep: make build-client
prep: make build-desktop prep: make build-desktop
daemon: make run RUN_CMD="bin/desktop --debug --log-level debug player run" daemon: make run RUN_CMD="bin/desktop --debug --log-level debug run"
} }