mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-02-16 01:47:48 +00:00
move connectObs
This commit is contained in:
parent
6320afdc18
commit
7d41439ad6
26
main.go
26
main.go
@ -126,19 +126,6 @@ func main() {
|
||||
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.
|
||||
// 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.
|
||||
@ -163,3 +150,16 @@ func run(ctx *kong.Context, obsCfg ObsConfig, styleCfg StyleConfig) error {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user