mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-04-27 14:36:47 +01:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb973c09f5 | |||
4fa32bfb42 | |||
8616f3b486 | |||
05f13ab87a | |||
71300a416b | |||
2fc2000b11 | |||
7692de752b | |||
107d1bca38 | |||
035b467a14 |
@ -5,6 +5,12 @@ 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/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# [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
|
||||
|
||||
### Added
|
||||
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Onyx and Iris
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
43
README.md
43
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)
|
||||
|
||||
## Installation
|
||||
|
||||
```console
|
||||
go install github.com/onyx-and-iris/gobs-cli@latest
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
#### Flags
|
||||
@ -121,6 +127,35 @@ gobs-cli sceneitem toggle --parent=test_group START "Colour Source 3"
|
||||
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
|
||||
|
||||
- list: List all groups.
|
||||
@ -273,7 +308,7 @@ gobs-cli scenecollection list
|
||||
gobs-cli scenecollection current
|
||||
```
|
||||
|
||||
- switch: "Switch scene collection.
|
||||
- switch: Switch scene collection.
|
||||
- args: Name
|
||||
|
||||
```console
|
||||
@ -305,21 +340,21 @@ gobs-cli profile current
|
||||
- args: Name
|
||||
|
||||
```console
|
||||
gobs-cli profile switch test-collection
|
||||
gobs-cli profile switch test-profile
|
||||
```
|
||||
|
||||
- create: Create profile.
|
||||
- args: Name
|
||||
|
||||
```console
|
||||
gobs-cli profile create test-collection
|
||||
gobs-cli profile create test-profile
|
||||
```
|
||||
|
||||
- remove: Remove profile.
|
||||
- args: Name
|
||||
|
||||
```console
|
||||
gobs-cli profile create test-collection
|
||||
gobs-cli profile remove test-profile
|
||||
```
|
||||
|
||||
### ReplayBufferCmd
|
||||
|
3
main.go
3
main.go
@ -46,7 +46,6 @@ type context struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var client *goobs.Client
|
||||
cli := cli{}
|
||||
ctx := kong.Parse(
|
||||
&cli,
|
||||
@ -55,9 +54,7 @@ func main() {
|
||||
)
|
||||
|
||||
client, err := connectObs(cli.ObsConfig)
|
||||
if err != nil {
|
||||
ctx.FatalIfErrorf(err)
|
||||
}
|
||||
|
||||
ctx.Bind(&context{
|
||||
Client: client,
|
||||
|
@ -12,7 +12,7 @@ type ProfileCmd struct {
|
||||
List ListProfileCmd `help:"List profiles." cmd:"" aliases:"ls"`
|
||||
Current CurrentProfileCmd `help:"Get current profile." cmd:"" aliases:"c"`
|
||||
Switch SwitchProfileCmd `help:"Switch profile." cmd:"" aliases:"sw"`
|
||||
Create CreateProfileCmd `help:"Create profile." cmd:"" aliases:"cr"`
|
||||
Create CreateProfileCmd `help:"Create profile." cmd:"" aliases:"new"`
|
||||
Remove RemoveProfileCmd `help:"Remove profile." cmd:"" aliases:"rm"`
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ type SceneCollectionCmd struct {
|
||||
List ListSceneCollectionCmd `help:"List scene collections." cmd:"" aliases:"ls"`
|
||||
Current CurrentSceneCollectionCmd `help:"Get current scene collection." cmd:"" aliases:"c"`
|
||||
Switch SwitchSceneCollectionCmd `help:"Switch scene collection." cmd:"" aliases:"sw"`
|
||||
Create CreateSceneCollectionCmd `help:"Create scene collection." cmd:"" aliases:"cr"`
|
||||
Create CreateSceneCollectionCmd `help:"Create scene collection." cmd:"" aliases:"new"`
|
||||
}
|
||||
|
||||
// ListSceneCollectionCmd provides a command to list all scene collections.
|
||||
|
129
sceneitem.go
129
sceneitem.go
@ -14,6 +14,7 @@ type SceneItemCmd struct {
|
||||
Hide SceneItemHideCmd `cmd:"" help:"Hide scene item." aliases:"h"`
|
||||
Toggle SceneItemToggleCmd `cmd:"" help:"Toggle scene item." aliases:"tg"`
|
||||
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.
|
||||
@ -85,6 +86,13 @@ func (cmd *SceneItemShowCmd) Run(ctx *context) error {
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
@ -110,6 +118,13 @@ func (cmd *SceneItemHideCmd) Run(ctx *context) error {
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
@ -151,6 +166,13 @@ func (cmd *SceneItemToggleCmd) Run(ctx *context) error {
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
@ -181,3 +203,110 @@ func (cmd *SceneItemVisibleCmd) Run(ctx *context) error {
|
||||
}
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user