This commit is contained in:
Noah Zoschke 2025-07-29 16:35:10 -07:00
parent e087fdefe3
commit c5e7bb4e1a

View File

@ -16,6 +16,7 @@ import (
// InputCmd provides commands to manage inputs in OBS Studio. // InputCmd provides commands to manage inputs in OBS Studio.
type InputCmd struct { type InputCmd struct {
Create InputCreateCmd `cmd:"" help:"Create input." aliases:"c"` Create InputCreateCmd `cmd:"" help:"Create input." aliases:"c"`
Delete InputDeleteCmd `cmd:"" help:"Delete input." aliases:"d"`
Kinds InputKindsCmd `cmd:"" help:"List input kinds." aliases:"k"` Kinds InputKindsCmd `cmd:"" help:"List input kinds." aliases:"k"`
List InputListCmd `cmd:"" help:"List all inputs." aliases:"ls"` List InputListCmd `cmd:"" help:"List all inputs." aliases:"ls"`
Mute InputMuteCmd `cmd:"" help:"Mute input." aliases:"m"` Mute InputMuteCmd `cmd:"" help:"Mute input." aliases:"m"`
@ -31,6 +32,11 @@ type InputCreateCmd struct {
Name string `arg:"" help:"Name for the input." required:""` Name string `arg:"" help:"Name for the input." required:""`
} }
// InputDeleteCmd provides a command to delete an input.
type InputDeleteCmd struct {
Name string `arg:"" help:"Name of the input to delete." required:""`
}
// InputListCmd provides a command to list all inputs. // InputListCmd provides a command to list all inputs.
type InputListCmd struct { type InputListCmd struct {
Input bool `flag:"" help:"List all inputs." aliases:"i"` Input bool `flag:"" help:"List all inputs." aliases:"i"`
@ -63,6 +69,19 @@ func (cmd *InputCreateCmd) Run(ctx *context) error {
return nil return nil
} }
// Run executes the command to delete an input.
func (cmd *InputDeleteCmd) Run(ctx *context) error {
_, err := ctx.Client.Inputs.RemoveInput(
inputs.NewRemoveInputParams().WithInputName(cmd.Name),
)
if err != nil {
return fmt.Errorf("failed to delete input: %w", err)
}
fmt.Fprintf(ctx.Out, "Deleted input: %s\n", ctx.Style.Highlight(cmd.Name))
return nil
}
// InputKindsCmd provides a command to list all input kinds. // InputKindsCmd provides a command to list all input kinds.
type InputKindsCmd struct{} type InputKindsCmd struct{}
@ -247,13 +266,19 @@ func (cmd *InputShowCmd) Run(ctx *context) error {
} }
var inputKind string var inputKind string
var found bool
for _, input := range lresp.Inputs { for _, input := range lresp.Inputs {
if input.InputName == cmd.Name { if input.InputName == cmd.Name {
inputKind = input.InputKind inputKind = input.InputKind
found = true
break break
} }
} }
if !found {
return fmt.Errorf("input '%s' not found", cmd.Name)
}
prop, name, _, err := device(ctx.Client, cmd.Name) prop, name, _, err := device(ctx.Client, cmd.Name)
if err != nil { if err != nil {
return fmt.Errorf("failed to get device: %w", err) return fmt.Errorf("failed to get device: %w", err)