mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-01-11 08:27:51 +00:00
create input
This commit is contained in:
parent
c6406888a9
commit
db70f8766d
29
input.go
29
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())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user