summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@posteo.de>2021-11-29 10:30:31 +0100
committerChristian Muehlhaeuser <muesli@gmail.com>2021-11-30 12:45:49 +0100
commitd29de81de2b0353646191b4c8d105ef3b36d4c99 (patch)
treec1ad216bbba1daeee49ebf9281d6b395b1908a54
parent614a165d3b3fa60f23bc58aee3514abbb323d113 (diff)
Add "scene list" commandv0.3.0
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 <bdrung@posteo.de>
-rw-r--r--README.md6
-rw-r--r--scene.go22
2 files changed, 28 insertions, 0 deletions
diff --git a/README.md b/README.md
index 26646bb..6f82312 100644
--- a/README.md
+++ b/README.md
@@ -72,6 +72,12 @@ obs-cli recording status
### Scenes
+List all scene names:
+
+```
+obs-cli scene list
+```
+
Switch program to a scene:
```
diff --git a/scene.go b/scene.go
index 064d455..e423ea3 100644
--- a/scene.go
+++ b/scene.go
@@ -2,6 +2,7 @@ package main
import (
"errors"
+ "fmt"
"strings"
"github.com/andreykaipov/goobs/api/requests/scenes"
@@ -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)",
@@ -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,
@@ -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)