Skip to content

Commit

Permalink
Add "scene list" command
Browse files Browse the repository at this point in the history
Since the scene name is required by multiple commands, add a `scene
list` command to list the available scene names.

Signed-off-by: Benjamin Drung <[email protected]>
  • Loading branch information
bdrung authored and muesli committed Nov 30, 2021
1 parent 614a165 commit d29de81
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ obs-cli recording status

### Scenes

List all scene names:

```
obs-cli scene list
```

Switch program to a scene:

```
Expand Down
22 changes: 22 additions & 0 deletions scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"errors"
"fmt"
"strings"

"github.com/andreykaipov/goobs/api/requests/scenes"
Expand All @@ -28,6 +29,14 @@ var (
},
}

listSceneCmd = &cobra.Command{
Use: "list",
Short: "List all scene names",
RunE: func(cmd *cobra.Command, args []string) error {
return listScenes()
},
}

previewSceneCmd = &cobra.Command{
Use: "preview",
Short: "Switch preview to a different scene (studio mode must be enabled)",
Expand All @@ -51,6 +60,18 @@ var (
}
)

func listScenes() error {
r, err := client.Scenes.GetSceneList()
if err != nil {
return err
}

for _, v := range r.Scenes {
fmt.Println(v.Name)
}
return nil
}

func setCurrentScene(scene string) error {
r := scenes.SetCurrentSceneParams{
SceneName: scene,
Expand Down Expand Up @@ -81,6 +102,7 @@ func switchScene(scene string) error {

func init() {
sceneCmd.AddCommand(currentSceneCmd)
sceneCmd.AddCommand(listSceneCmd)
sceneCmd.AddCommand(previewSceneCmd)
sceneCmd.AddCommand(switchSceneCmd)
rootCmd.AddCommand(sceneCmd)
Expand Down

0 comments on commit d29de81

Please sign in to comment.