mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-01-11 16:37:49 +00:00
kinds
This commit is contained in:
parent
cb735cd666
commit
72fc7d4092
42
input.go
42
input.go
@ -15,6 +15,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"`
|
||||||
|
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"`
|
||||||
Unmute InputUnmuteCmd `cmd:"" help:"Unmute input." aliases:"um"`
|
Unmute InputUnmuteCmd `cmd:"" help:"Unmute input." aliases:"um"`
|
||||||
@ -60,6 +61,47 @@ func (cmd *InputCreateCmd) Run(ctx *context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InputKindsCmd provides a command to list all input kinds.
|
||||||
|
type InputKindsCmd struct{}
|
||||||
|
|
||||||
|
// Run executes the command to list all input kinds.
|
||||||
|
func (cmd *InputKindsCmd) Run(ctx *context) error {
|
||||||
|
resp, err := ctx.Client.Inputs.GetInputKindList(
|
||||||
|
inputs.NewGetInputKindListParams().WithUnversioned(false),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get input kinds: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t := table.New().Border(lipgloss.RoundedBorder()).
|
||||||
|
BorderStyle(lipgloss.NewStyle().Foreground(ctx.Style.border))
|
||||||
|
t.Headers("Kind")
|
||||||
|
t.StyleFunc(func(row, col int) lipgloss.Style {
|
||||||
|
style := lipgloss.NewStyle().Padding(0, 3)
|
||||||
|
switch col {
|
||||||
|
case 0:
|
||||||
|
style = style.Align(lipgloss.Left)
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case row == table.HeaderRow:
|
||||||
|
style = style.Bold(true).Align(lipgloss.Center)
|
||||||
|
case row%2 == 0:
|
||||||
|
style = style.Foreground(ctx.Style.evenRows)
|
||||||
|
default:
|
||||||
|
style = style.Foreground(ctx.Style.oddRows)
|
||||||
|
}
|
||||||
|
return style
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, kind := range resp.InputKinds {
|
||||||
|
t.Row(kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintln(ctx.Out, t.Render())
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Run executes the command to list all inputs.
|
// Run executes the command to list all inputs.
|
||||||
func (cmd *InputListCmd) Run(ctx *context) error {
|
func (cmd *InputListCmd) Run(ctx *context) error {
|
||||||
resp, err := ctx.Client.Inputs.GetInputList(inputs.NewGetInputListParams())
|
resp, err := ctx.Client.Inputs.GetInputList(inputs.NewGetInputListParams())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user