mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-04-18 07:03:37 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c653047c66 | |||
| 30fabe8cfc | |||
| 8cf969c906 | |||
| 3540c60c4b | |||
| b2c5980b4a | |||
| da1ef9f993 | |||
| 0a2c622645 | |||
| cb973c09f5 | |||
| 4fa32bfb42 | |||
| 8616f3b486 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -26,5 +26,15 @@ go.work
|
|||||||
|
|
||||||
# End of gignore: github.com/onyx-and-iris/gignore
|
# End of gignore: github.com/onyx-and-iris/gignore
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
.env
|
||||||
.envrc
|
.envrc
|
||||||
|
|
||||||
|
# Man pages
|
||||||
|
gobs-cli.1
|
||||||
|
|
||||||
|
# Config files
|
||||||
|
config.yaml
|
||||||
|
|
||||||
|
# Test files
|
||||||
*_test.go
|
*_test.go
|
||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -5,6 +5,19 @@ 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.3.1] - 2024-05-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- --man flag for generating/viewing a man page.
|
||||||
|
- Ability to load env vars from env files, see the [README](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#environment-variables)
|
||||||
|
|
||||||
|
# [0.2.0] - 2025-04-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- sceneitem transform, see *transform* under [SceneItemCmd](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#sceneitemcmd)
|
||||||
|
|
||||||
# [0.1.0] - 2025-04-24
|
# [0.1.0] - 2025-04-24
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
53
README.md
53
README.md
@@ -4,6 +4,12 @@ A command line interface for OBS Websocket v5
|
|||||||
|
|
||||||
For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```console
|
||||||
|
go install github.com/onyx-and-iris/gobs-cli@latest
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
#### Flags
|
#### Flags
|
||||||
@@ -16,17 +22,19 @@ gobs-cli --host=localhost --port=4455 --password=<websocket password> --help
|
|||||||
|
|
||||||
#### Environment Variables
|
#### Environment Variables
|
||||||
|
|
||||||
Load connection details from your environment:
|
Store and load environment variables from:
|
||||||
|
|
||||||
```bash
|
- A `.env` file in the cwd
|
||||||
#!/usr/bin/env bash
|
- $XDG_CONFIG_HOME / gobs-cli / config.env (see [os.UserConfigDir][userconfigdir])
|
||||||
|
|
||||||
export OBS_HOST=localhost
|
```env
|
||||||
export OBS_PORT=4455
|
OBS_HOST=localhost
|
||||||
export OBS_PASSWORD=<websocket password>
|
OBS_PORT=4455
|
||||||
export OBS_TIMEOUT=5
|
OBS_PASSWORD=<websocket password>
|
||||||
|
OBS_TIMEOUT=5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
### VersionCmd
|
### VersionCmd
|
||||||
@@ -121,6 +129,35 @@ gobs-cli sceneitem toggle --parent=test_group START "Colour Source 3"
|
|||||||
gobs-cli sceneitem visible --parent=test_group START "Colour Source 4"
|
gobs-cli sceneitem visible --parent=test_group START "Colour Source 4"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- transform: Transform scene item.
|
||||||
|
- flags:
|
||||||
|
*optional*
|
||||||
|
- --parent: Parent group name.
|
||||||
|
|
||||||
|
- --alignment: Alignment of the scene item.
|
||||||
|
- --bounds-alignment: Bounds alignment of the scene item.
|
||||||
|
- --bounds-height: Bounds height of the scene item.
|
||||||
|
- --bounds-type: Bounds type of the scene item.
|
||||||
|
- --bounds-width: Bounds width of the scene item.
|
||||||
|
- --crop-to-bounds: Whether to crop the scene item to bounds.
|
||||||
|
- --crop-bottom: Crop bottom value of the scene item.
|
||||||
|
- --crop-left: Crop left value of the scene item.
|
||||||
|
- --crop-right: Crop right value of the scene item.
|
||||||
|
- --crop-top: Crop top value of the scene item.
|
||||||
|
- --position-x: X position of the scene item.
|
||||||
|
- --position-y: Y position of the scene item.
|
||||||
|
- --rotation: Rotation of the scene item.
|
||||||
|
- --scale-x: X scale of the scene item.
|
||||||
|
- --scale-y: Y scale of the scene item.
|
||||||
|
- args: SceneName ItemName
|
||||||
|
|
||||||
|
```console
|
||||||
|
gobs-cli sceneitem transform \
|
||||||
|
--rotation=5 \
|
||||||
|
--position-x=250.8 \
|
||||||
|
Scene "Colour Source 3"
|
||||||
|
```
|
||||||
|
|
||||||
### GroupCmd
|
### GroupCmd
|
||||||
|
|
||||||
- list: List all groups.
|
- list: List all groups.
|
||||||
@@ -399,3 +436,5 @@ gobs-cli virtualcam toggle
|
|||||||
```console
|
```console
|
||||||
gobs-cli virtualcam status
|
gobs-cli virtualcam status
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[userconfigdir]: https://pkg.go.dev/os#UserConfigDir
|
||||||
17
Taskfile.man.yaml
Normal file
17
Taskfile.man.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
|
desc: View man page
|
||||||
|
cmds:
|
||||||
|
- task: view
|
||||||
|
|
||||||
|
view:
|
||||||
|
desc: View man page
|
||||||
|
cmds:
|
||||||
|
- go run . --man | man -l -
|
||||||
|
|
||||||
|
generate:
|
||||||
|
desc: Generate man page
|
||||||
|
cmds:
|
||||||
|
- go run . --man > {{.PROGRAM}}.1
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
man: Taskfile.man.yaml
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
PROGRAM: gobs-cli
|
PROGRAM: gobs-cli
|
||||||
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||||
|
|||||||
5
go.mod
5
go.mod
@@ -4,14 +4,19 @@ go 1.24.0
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/kong v1.10.0
|
github.com/alecthomas/kong v1.10.0
|
||||||
|
github.com/alecthomas/mango-kong v0.1.0
|
||||||
github.com/andreykaipov/goobs v1.5.6
|
github.com/andreykaipov/goobs v1.5.6
|
||||||
|
github.com/titusjaka/kong-dotenv-go v0.1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/hashicorp/logutils v1.0.0 // indirect
|
github.com/hashicorp/logutils v1.0.0 // indirect
|
||||||
|
github.com/joho/godotenv v1.5.1 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/mmcloughlin/profile v0.1.1 // indirect
|
github.com/mmcloughlin/profile v0.1.1 // indirect
|
||||||
|
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab // indirect
|
||||||
|
github.com/muesli/roff v0.1.0 // indirect
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
10
go.sum
10
go.sum
@@ -2,6 +2,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v
|
|||||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||||
github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw=
|
github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw=
|
||||||
github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
|
github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
|
||||||
|
github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4=
|
||||||
|
github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4=
|
||||||
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
|
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
|
||||||
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||||
github.com/andreykaipov/goobs v1.5.6 h1:eIkEqYN99+2VJvmlY/56Ah60nkRKS6efMQvpM3oUgPQ=
|
github.com/andreykaipov/goobs v1.5.6 h1:eIkEqYN99+2VJvmlY/56Ah60nkRKS6efMQvpM3oUgPQ=
|
||||||
@@ -16,15 +18,23 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
|
|||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/mmcloughlin/profile v0.1.1 h1:jhDmAqPyebOsVDOCICJoINoLb/AnLBaUw58nFzxWS2w=
|
github.com/mmcloughlin/profile v0.1.1 h1:jhDmAqPyebOsVDOCICJoINoLb/AnLBaUw58nFzxWS2w=
|
||||||
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||||
|
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab h1:m7QFONkzLK0fVXCjwX5tANcnj1yXxTnYQtnfJiY3tcA=
|
||||||
|
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
|
||||||
|
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
|
||||||
|
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/titusjaka/kong-dotenv-go v0.1.0 h1:TmUjP/sXoNiKLr6oR7n9xrB5XyXi/Ssuebzfz5nxZj4=
|
||||||
|
github.com/titusjaka/kong-dotenv-go v0.1.0/go.mod h1:pBgLjcu82oqUgb7+bngK9+Ch7jg49E0YADP8Wnj2MXU=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
14
main.go
14
main.go
@@ -7,10 +7,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
|
mangokong "github.com/alecthomas/mango-kong"
|
||||||
"github.com/andreykaipov/goobs"
|
"github.com/andreykaipov/goobs"
|
||||||
|
kongdotenv "github.com/titusjaka/kong-dotenv-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObsConfig holds the configuration for connecting to the OBS WebSocket server.
|
// ObsConfig holds the configuration for connecting to the OBS WebSocket server.
|
||||||
@@ -26,6 +29,8 @@ type ObsConfig struct {
|
|||||||
type cli struct {
|
type cli struct {
|
||||||
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
||||||
|
|
||||||
|
Man mangokong.ManFlag `help:"Print man page."`
|
||||||
|
|
||||||
Version VersionCmd `help:"Show version." cmd:"" aliases:"v"`
|
Version VersionCmd `help:"Show version." cmd:"" aliases:"v"`
|
||||||
Scene SceneCmd `help:"Manage scenes." cmd:"" aliases:"sc"`
|
Scene SceneCmd `help:"Manage scenes." cmd:"" aliases:"sc"`
|
||||||
Sceneitem SceneItemCmd `help:"Manage scene items." cmd:"" aliases:"si"`
|
Sceneitem SceneItemCmd `help:"Manage scene items." cmd:"" aliases:"si"`
|
||||||
@@ -46,11 +51,18 @@ type context struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cli := cli{}
|
userConfigDir, err := os.UserConfigDir()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error getting user config directory: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
var cli cli
|
||||||
ctx := kong.Parse(
|
ctx := kong.Parse(
|
||||||
&cli,
|
&cli,
|
||||||
kong.Name("GOBS-CLI"),
|
kong.Name("GOBS-CLI"),
|
||||||
kong.Description("A command line tool to interact with OBS Websocket."),
|
kong.Description("A command line tool to interact with OBS Websocket."),
|
||||||
|
kong.Configuration(kongdotenv.ENVFileReader, ".env", filepath.Join(userConfigDir, "gobs-cli", "config.env")),
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := connectObs(cli.ObsConfig)
|
client, err := connectObs(cli.ObsConfig)
|
||||||
|
|||||||
129
sceneitem.go
129
sceneitem.go
@@ -14,6 +14,7 @@ type SceneItemCmd struct {
|
|||||||
Hide SceneItemHideCmd `cmd:"" help:"Hide scene item." aliases:"h"`
|
Hide SceneItemHideCmd `cmd:"" help:"Hide scene item." aliases:"h"`
|
||||||
Toggle SceneItemToggleCmd `cmd:"" help:"Toggle scene item." aliases:"tg"`
|
Toggle SceneItemToggleCmd `cmd:"" help:"Toggle scene item." aliases:"tg"`
|
||||||
Visible SceneItemVisibleCmd `cmd:"" help:"Get scene item visibility." aliases:"v"`
|
Visible SceneItemVisibleCmd `cmd:"" help:"Get scene item visibility." aliases:"v"`
|
||||||
|
Transform SceneItemTransformCmd `cmd:"" help:"Transform scene item." aliases:"t"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SceneItemListCmd provides a command to list all scene items in a scene.
|
// SceneItemListCmd provides a command to list all scene items in a scene.
|
||||||
@@ -85,6 +86,13 @@ func (cmd *SceneItemShowCmd) Run(ctx *context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cmd.Parent != "" {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in group '%s' is now visible.\n", cmd.ItemName, cmd.Parent)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in scene '%s' is now visible.\n", cmd.ItemName, cmd.SceneName)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +118,13 @@ func (cmd *SceneItemHideCmd) Run(ctx *context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cmd.Parent != "" {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in group '%s' is now hidden.\n", cmd.ItemName, cmd.Parent)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in scene '%s' is now hidden.\n", cmd.ItemName, cmd.SceneName)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +166,13 @@ func (cmd *SceneItemToggleCmd) Run(ctx *context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if itemEnabled {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in scene '%s' is now hidden.\n", cmd.ItemName, cmd.SceneName)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in scene '%s' is now visible.\n", cmd.ItemName, cmd.SceneName)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,3 +203,110 @@ func (cmd *SceneItemVisibleCmd) Run(ctx *context) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SceneItemTransformCmd provides a command to transform a scene item.
|
||||||
|
type SceneItemTransformCmd struct {
|
||||||
|
SceneName string `arg:"" help:"Scene name."`
|
||||||
|
ItemName string `arg:"" help:"Item name."`
|
||||||
|
|
||||||
|
Parent string `flag:"" help:"Parent group name."`
|
||||||
|
|
||||||
|
Alignment float64 `flag:"" help:"Alignment of the scene item."`
|
||||||
|
BoundsAlignment float64 `flag:"" help:"Bounds alignment of the scene item."`
|
||||||
|
BoundsHeight float64 `flag:"" help:"Bounds height of the scene item." default:"1.0"`
|
||||||
|
BoundsType string `flag:"" help:"Bounds type of the scene item." default:"OBS_BOUNDS_NONE"`
|
||||||
|
BoundsWidth float64 `flag:"" help:"Bounds width of the scene item." default:"1.0"`
|
||||||
|
CropToBounds bool `flag:"" help:"Whether to crop the scene item to bounds."`
|
||||||
|
CropBottom float64 `flag:"" help:"Crop bottom value of the scene item."`
|
||||||
|
CropLeft float64 `flag:"" help:"Crop left value of the scene item."`
|
||||||
|
CropRight float64 `flag:"" help:"Crop right value of the scene item."`
|
||||||
|
CropTop float64 `flag:"" help:"Crop top value of the scene item."`
|
||||||
|
PositionX float64 `flag:"" help:"X position of the scene item."`
|
||||||
|
PositionY float64 `flag:"" help:"Y position of the scene item."`
|
||||||
|
Rotation float64 `flag:"" help:"Rotation of the scene item."`
|
||||||
|
ScaleX float64 `flag:"" help:"X scale of the scene item."`
|
||||||
|
ScaleY float64 `flag:"" help:"Y scale of the scene item."`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run executes the command to transform a scene item.
|
||||||
|
func (cmd *SceneItemTransformCmd) Run(ctx *context) error {
|
||||||
|
sceneName, sceneItemID, err := getSceneNameAndItemID(ctx.Client, cmd.SceneName, cmd.ItemName, cmd.Parent)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current transform of the scene item
|
||||||
|
resp, err := ctx.Client.SceneItems.GetSceneItemTransform(sceneitems.NewGetSceneItemTransformParams().
|
||||||
|
WithSceneName(sceneName).
|
||||||
|
WithSceneItemId(sceneItemID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the transform with the provided values
|
||||||
|
transform := resp.SceneItemTransform
|
||||||
|
|
||||||
|
if cmd.Alignment != 0 {
|
||||||
|
transform.Alignment = cmd.Alignment
|
||||||
|
}
|
||||||
|
if cmd.BoundsAlignment != 0 {
|
||||||
|
transform.BoundsAlignment = cmd.BoundsAlignment
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.BoundsHeight != 0 {
|
||||||
|
transform.BoundsHeight = cmd.BoundsHeight
|
||||||
|
}
|
||||||
|
if cmd.BoundsType != "" {
|
||||||
|
transform.BoundsType = cmd.BoundsType
|
||||||
|
}
|
||||||
|
if cmd.BoundsWidth != 0 {
|
||||||
|
transform.BoundsWidth = cmd.BoundsWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.CropToBounds {
|
||||||
|
transform.CropToBounds = cmd.CropToBounds
|
||||||
|
}
|
||||||
|
if cmd.CropBottom != 0 {
|
||||||
|
transform.CropBottom = cmd.CropBottom
|
||||||
|
}
|
||||||
|
if cmd.CropLeft != 0 {
|
||||||
|
transform.CropLeft = cmd.CropLeft
|
||||||
|
}
|
||||||
|
if cmd.CropRight != 0 {
|
||||||
|
transform.CropRight = cmd.CropRight
|
||||||
|
}
|
||||||
|
if cmd.CropTop != 0 {
|
||||||
|
transform.CropTop = cmd.CropTop
|
||||||
|
}
|
||||||
|
if cmd.PositionX != 0 {
|
||||||
|
transform.PositionX = cmd.PositionX
|
||||||
|
}
|
||||||
|
if cmd.PositionY != 0 {
|
||||||
|
transform.PositionY = cmd.PositionY
|
||||||
|
}
|
||||||
|
if cmd.Rotation != 0 {
|
||||||
|
transform.Rotation = cmd.Rotation
|
||||||
|
}
|
||||||
|
if cmd.ScaleX != 0 {
|
||||||
|
transform.ScaleX = cmd.ScaleX
|
||||||
|
}
|
||||||
|
if cmd.ScaleY != 0 {
|
||||||
|
transform.ScaleY = cmd.ScaleY
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ctx.Client.SceneItems.SetSceneItemTransform(sceneitems.NewSetSceneItemTransformParams().
|
||||||
|
WithSceneName(sceneName).
|
||||||
|
WithSceneItemId(sceneItemID).
|
||||||
|
WithSceneItemTransform(transform))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd.Parent != "" {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in group '%s' transformed.\n", cmd.ItemName, cmd.Parent)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(ctx.Out, "Scene item '%s' in scene '%s' transformed.\n", cmd.ItemName, cmd.SceneName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user