From db70f8766da4023a32b8683c4a17accc1b55591a Mon Sep 17 00:00:00 2001 From: Noah Zoschke Date: Tue, 29 Jul 2025 14:30:49 -0700 Subject: [PATCH] create input --- input.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/input.go b/input.go index 9761068..c9d2a59 100644 --- a/input.go +++ b/input.go @@ -13,12 +13,19 @@ import ( // InputCmd provides commands to manage inputs in OBS Studio. type InputCmd struct { + Create InputCreateCmd `cmd:"" help:"Create input." aliases:"c"` List InputListCmd `cmd:"" help:"List all inputs." aliases:"ls"` Mute InputMuteCmd `cmd:"" help:"Mute input." aliases:"m"` Unmute InputUnmuteCmd `cmd:"" help:"Unmute input." aliases:"um"` Toggle InputToggleCmd `cmd:"" help:"Toggle input." aliases:"tg"` } +// InputCreateCmd provides a command to create an input. +type InputCreateCmd struct { + Kind string `arg:"" help:"Input kind (e.g., coreaudio_input_capture, macos-avcapture)." required:""` + Name string `arg:"" help:"Name for the input." required:""` +} + // InputListCmd provides a command to list all inputs. type InputListCmd struct { Input bool `flag:"" help:"List all inputs." aliases:"i"` @@ -29,6 +36,28 @@ type InputListCmd struct { UUID bool `flag:"" help:"Display UUIDs of inputs." aliases:"u"` } +// Run executes the command to create an input. +func (cmd *InputCreateCmd) Run(ctx *context) error { + currentScene, err := ctx.Client.Scenes.GetCurrentProgramScene() + if err != nil { + return err + } + + _, err = ctx.Client.Inputs.CreateInput( + inputs.NewCreateInputParams(). + WithInputKind(cmd.Kind). + WithInputName(cmd.Name). + WithSceneName(currentScene.CurrentProgramSceneName), + ) + if err != nil { + return err + } + + fmt.Fprintf(ctx.Out, "Created input: %s (%s) in scene %s\n", + ctx.Style.Highlight(cmd.Name), cmd.Kind, ctx.Style.Highlight(currentScene.CurrentProgramSceneName)) + return nil +} + // Run executes the command to list all inputs. func (cmd *InputListCmd) Run(ctx *context) error { resp, err := ctx.Client.Inputs.GetInputList(inputs.NewGetInputListParams())