diff options
author | Benjamin Drung <bdrung@posteo.de> | 2021-11-29 10:30:31 +0100 |
---|---|---|
committer | Christian Muehlhaeuser <muesli@gmail.com> | 2021-11-30 12:45:49 +0100 |
commit | d29de81de2b0353646191b4c8d105ef3b36d4c99 (patch) | |
tree | c1ad216bbba1daeee49ebf9281d6b395b1908a54 | |
parent | 614a165d3b3fa60f23bc58aee3514abbb323d113 (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.md | 6 | ||||
-rw-r--r-- | scene.go | 22 |
2 files changed, 28 insertions, 0 deletions
@@ -72,6 +72,12 @@ obs-cli recording status ### Scenes +List all scene names: + +``` +obs-cli scene list +``` + Switch program to a scene: ``` @@ -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) |