mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-08-07 12:11:53 +00:00
Compare commits
No commits in common. "c6406888a9ae39fe171e9ecf5a66c47573077ede" and "9eb6c8a282398e7f7d1590e024e45939ab3443b1" have entirely different histories.
c6406888a9
...
9eb6c8a282
@ -5,12 +5,6 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
# [0.14.1] - 2025-07-14
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- text command group, see [TextCmd](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#textcmd)
|
|
||||||
|
|
||||||
# [0.13.3] - 2025-06-27
|
# [0.13.3] - 2025-06-27
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
16
README.md
16
README.md
@ -302,22 +302,6 @@ gobs-cli input unmute "Mic/Aux"
|
|||||||
gobs-cli input toggle "Mic/Aux"
|
gobs-cli input toggle "Mic/Aux"
|
||||||
```
|
```
|
||||||
|
|
||||||
### TextCmd
|
|
||||||
|
|
||||||
- current: Display current text for a text input.
|
|
||||||
- args: InputName
|
|
||||||
|
|
||||||
```console
|
|
||||||
gobs-cli text current "My Text Input"
|
|
||||||
```
|
|
||||||
|
|
||||||
- update: Update the text of a text input.
|
|
||||||
- args: InputName NewText
|
|
||||||
|
|
||||||
```console
|
|
||||||
gobs-cli text update "My Text Input" "hi OBS!"
|
|
||||||
```
|
|
||||||
|
|
||||||
### RecordCmd
|
### RecordCmd
|
||||||
|
|
||||||
- start: Start recording.
|
- start: Start recording.
|
||||||
|
1
main.go
1
main.go
@ -59,7 +59,6 @@ type CLI struct {
|
|||||||
Sceneitem SceneItemCmd `help:"Manage scene items." cmd:"" aliases:"si" group:"Scene Item"`
|
Sceneitem SceneItemCmd `help:"Manage scene items." cmd:"" aliases:"si" group:"Scene Item"`
|
||||||
Group GroupCmd `help:"Manage groups." cmd:"" aliases:"g" group:"Group"`
|
Group GroupCmd `help:"Manage groups." cmd:"" aliases:"g" group:"Group"`
|
||||||
Input InputCmd `help:"Manage inputs." cmd:"" aliases:"i" group:"Input"`
|
Input InputCmd `help:"Manage inputs." cmd:"" aliases:"i" group:"Input"`
|
||||||
Text TextCmd `help:"Manage text inputs." cmd:"" aliases:"t" group:"Text Input"`
|
|
||||||
Record RecordCmd `help:"Manage recording." cmd:"" aliases:"rec" group:"Recording"`
|
Record RecordCmd `help:"Manage recording." cmd:"" aliases:"rec" group:"Recording"`
|
||||||
Stream StreamCmd `help:"Manage streaming." cmd:"" aliases:"st" group:"Streaming"`
|
Stream StreamCmd `help:"Manage streaming." cmd:"" aliases:"st" group:"Streaming"`
|
||||||
Scenecollection SceneCollectionCmd `help:"Manage scene collections." cmd:"" aliases:"scn" group:"Scene Collection"`
|
Scenecollection SceneCollectionCmd `help:"Manage scene collections." cmd:"" aliases:"scn" group:"Scene Collection"`
|
||||||
|
85
text.go
85
text.go
@ -1,85 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/andreykaipov/goobs/api/requests/inputs"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TextCmd provides commands for managing text inputs in OBS.
|
|
||||||
type TextCmd struct {
|
|
||||||
Current TextCurrentCmd `cmd:"current" help:"Display current text for a text input." aliases:"c"`
|
|
||||||
Update TextUpdateCmd `cmd:"update" help:"Update the text of a text input." aliases:"u"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// TextCurrentCmd provides a command to display the current text of a text input.
|
|
||||||
type TextCurrentCmd struct {
|
|
||||||
InputName string `arg:"" help:"Name of the text source."`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run executes the command to display the current text of a text input.
|
|
||||||
func (cmd *TextCurrentCmd) Run(ctx *context) error {
|
|
||||||
resp, err := ctx.Client.Inputs.GetInputSettings(
|
|
||||||
inputs.NewGetInputSettingsParams().WithInputName(cmd.InputName),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to get input settings: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the input is a text input
|
|
||||||
kind := resp.InputKind
|
|
||||||
if !strings.HasPrefix(kind, "text_") {
|
|
||||||
return fmt.Errorf("input %s is of %s", cmd.InputName, kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentText, ok := resp.InputSettings["text"]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("input %s does not have a 'text' setting", cmd.InputName)
|
|
||||||
}
|
|
||||||
if currentText == "" {
|
|
||||||
currentText = "(empty)"
|
|
||||||
}
|
|
||||||
fmt.Fprintf(
|
|
||||||
ctx.Out,
|
|
||||||
"Current text for source %s: %s\n",
|
|
||||||
ctx.Style.Highlight(cmd.InputName),
|
|
||||||
currentText,
|
|
||||||
)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TextUpdateCmd provides a command to update the text of a text input.
|
|
||||||
type TextUpdateCmd struct {
|
|
||||||
InputName string `arg:"" help:"Name of the text source."`
|
|
||||||
NewText string `arg:"" help:"New text to set for the source." default:""`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run executes the command to update the text of a text input.
|
|
||||||
func (cmd *TextUpdateCmd) Run(ctx *context) error {
|
|
||||||
resp, err := ctx.Client.Inputs.GetInputSettings(
|
|
||||||
inputs.NewGetInputSettingsParams().WithInputName(cmd.InputName),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to get input settings: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the input is a text input
|
|
||||||
kind := resp.InputKind
|
|
||||||
if !strings.HasPrefix(kind, "text_") {
|
|
||||||
return fmt.Errorf("input %s is of %s", cmd.InputName, kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := ctx.Client.Inputs.SetInputSettings(&inputs.SetInputSettingsParams{
|
|
||||||
InputName: &cmd.InputName,
|
|
||||||
InputSettings: map[string]any{"text": &cmd.NewText},
|
|
||||||
}); err != nil {
|
|
||||||
return fmt.Errorf("failed to update text for source %s: %w", cmd.InputName, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if cmd.NewText == "" {
|
|
||||||
cmd.NewText = "(empty)"
|
|
||||||
}
|
|
||||||
fmt.Fprintf(ctx.Out, "Updated text for source %s to: %s\n", ctx.Style.Highlight(cmd.InputName), cmd.NewText)
|
|
||||||
return nil
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user