move connectObs

This commit is contained in:
onyx-and-iris 2026-02-13 08:04:44 +00:00
parent 6320afdc18
commit 7d41439ad6

26
main.go
View File

@ -126,19 +126,6 @@ func main() {
ctx.FatalIfErrorf(run(ctx, cli.ObsConfig, cli.StyleConfig)) ctx.FatalIfErrorf(run(ctx, cli.ObsConfig, cli.StyleConfig))
} }
// connectObs creates a new OBS client and connects to the OBS WebSocket server.
func connectObs(cfg ObsConfig) (*goobs.Client, error) {
client, err := goobs.New(
fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
goobs.WithPassword(cfg.Password),
goobs.WithResponseTimeout(time.Duration(cfg.Timeout)*time.Second),
)
if err != nil {
return nil, err
}
return client, nil
}
// run executes the command line interface. // run executes the command line interface.
// It connects to the OBS WebSocket server and binds the context to the selected command. // It connects to the OBS WebSocket server and binds the context to the selected command.
// It also handles the "completion" command separately to avoid unnecessary connections. // It also handles the "completion" command separately to avoid unnecessary connections.
@ -163,3 +150,16 @@ func run(ctx *kong.Context, obsCfg ObsConfig, styleCfg StyleConfig) error {
return ctx.Run() return ctx.Run()
} }
// connectObs creates a new OBS client and connects to the OBS WebSocket server.
func connectObs(cfg ObsConfig) (*goobs.Client, error) {
client, err := goobs.New(
fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
goobs.WithPassword(cfg.Password),
goobs.WithResponseTimeout(time.Duration(cfg.Timeout)*time.Second),
)
if err != nil {
return nil, err
}
return client, nil
}