From c5e7bb4e1a3b6d83cf2538bad6cabd264e4fe966 Mon Sep 17 00:00:00 2001 From: Noah Zoschke Date: Tue, 29 Jul 2025 16:35:10 -0700 Subject: [PATCH] delete --- input.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/input.go b/input.go index bb7c5e7..f7d80d8 100644 --- a/input.go +++ b/input.go @@ -16,6 +16,7 @@ import ( // InputCmd provides commands to manage inputs in OBS Studio. type InputCmd struct { 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"` List InputListCmd `cmd:"" help:"List all inputs." aliases:"ls"` Mute InputMuteCmd `cmd:"" help:"Mute input." aliases:"m"` @@ -31,6 +32,11 @@ type InputCreateCmd struct { 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. type InputListCmd struct { Input bool `flag:"" help:"List all inputs." aliases:"i"` @@ -63,6 +69,19 @@ func (cmd *InputCreateCmd) Run(ctx *context) error { 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. type InputKindsCmd struct{} @@ -247,13 +266,19 @@ func (cmd *InputShowCmd) Run(ctx *context) error { } var inputKind string + var found bool for _, input := range lresp.Inputs { if input.InputName == cmd.Name { inputKind = input.InputKind + found = true break } } + if !found { + return fmt.Errorf("input '%s' not found", cmd.Name) + } + prop, name, _, err := device(ctx.Client, cmd.Name) if err != nil { return fmt.Errorf("failed to get device: %w", err)