mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-03-03 16:59:13 +00:00
Compare commits
No commits in common. "7855ce5d54a659416f39a5c024a93cc408c7082b" and "cbd518ca0fdb87f5fe3edff8a3d4726a98e9ffb4" have entirely different histories.
7855ce5d54
...
cbd518ca0f
30
.github/workflows/update-go-modules.yml
vendored
30
.github/workflows/update-go-modules.yml
vendored
@ -1,30 +0,0 @@
|
|||||||
name: Auto-Update Go Modules
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * 1' # Runs every Monday at midnight
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-go-modules:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: stable
|
|
||||||
|
|
||||||
- name: Update Dependencies
|
|
||||||
run: |
|
|
||||||
go get -u ./...
|
|
||||||
go mod tidy
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add go.mod go.sum
|
|
||||||
git commit -m "chore: auto-update Go modules"
|
|
||||||
git push
|
|
||||||
23
main.go
23
main.go
@ -123,7 +123,12 @@ func main() {
|
|||||||
}(),
|
}(),
|
||||||
})
|
})
|
||||||
|
|
||||||
ctx.FatalIfErrorf(run(ctx, cli.ObsConfig, cli.StyleConfig))
|
client, err := connectObs(cli.ObsConfig)
|
||||||
|
ctx.FatalIfErrorf(err)
|
||||||
|
|
||||||
|
ctx.Bind(newContext(client, os.Stdout, cli.StyleConfig))
|
||||||
|
|
||||||
|
ctx.FatalIfErrorf(run(ctx, client))
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectObs creates a new OBS client and connects to the OBS WebSocket server.
|
// connectObs creates a new OBS client and connects to the OBS WebSocket server.
|
||||||
@ -140,18 +145,8 @@ func connectObs(cfg ObsConfig) (*goobs.Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 disconnects the OBS client after the command is executed.
|
||||||
// It also handles the "completion" command separately to avoid unnecessary connections.
|
func run(ctx *kong.Context, client *goobs.Client) error {
|
||||||
func run(ctx *kong.Context, obsCfg ObsConfig, styleCfg StyleConfig) error {
|
|
||||||
if ctx.Selected().Name == "completion" {
|
|
||||||
return ctx.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := connectObs(obsCfg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() error {
|
defer func() error {
|
||||||
if err := client.Disconnect(); err != nil {
|
if err := client.Disconnect(); err != nil {
|
||||||
return fmt.Errorf("failed to disconnect from OBS: %w", err)
|
return fmt.Errorf("failed to disconnect from OBS: %w", err)
|
||||||
@ -159,7 +154,5 @@ func run(ctx *kong.Context, obsCfg ObsConfig, styleCfg StyleConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx.Bind(newContext(client, os.Stdout, styleCfg))
|
|
||||||
|
|
||||||
return ctx.Run()
|
return ctx.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user