mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-04-18 07:03:37 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4446784709 | |||
| 89a5add7ad | |||
| 878ecbd33e | |||
| 18a90e727f | |||
| 95ebb2afb6 | |||
| 666b4cf744 | |||
| 9ee6fa9e34 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -5,6 +5,16 @@ 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.9.0]
|
||||
|
||||
### Added
|
||||
|
||||
- --version/-v option. See [VersionFlag](https://github.com/onyx-and-iris/gobs-cli?tab=readme-ov-file#versionflag)
|
||||
|
||||
### Changed
|
||||
|
||||
- version command renamed to obs-version
|
||||
|
||||
# [0.8.2]
|
||||
|
||||
### Added
|
||||
|
||||
18
README.md
18
README.md
@@ -14,10 +14,16 @@ go install github.com/onyx-and-iris/gobs-cli@latest
|
||||
|
||||
#### Flags
|
||||
|
||||
Pass `--host`, `--port` and `--password` as flags to the root command, for example:
|
||||
- --host/-H: Websocket host
|
||||
- --port/-P Websocket port
|
||||
- --password/-p: Websocket password
|
||||
- --timeout/-T: Websocket timeout
|
||||
- --version/-v: Print the gobs-cli version
|
||||
|
||||
Pass `--host`, `--port` and `--password` as flags on the root command, for example:
|
||||
|
||||
```console
|
||||
gobs-cli --host=localhost --port=4455 --password=<websocket password> --help
|
||||
gobs-cli --host localhost --port 4455 --password 'websocket password' --help
|
||||
```
|
||||
|
||||
#### Environment Variables
|
||||
@@ -37,10 +43,12 @@ OBS_TIMEOUT=5
|
||||
|
||||
## Commands
|
||||
|
||||
### VersionCmd
|
||||
### ObsVersionCmd
|
||||
|
||||
- Print OBS client and websocket version.
|
||||
|
||||
```console
|
||||
gobs-cli version
|
||||
gobs-cli obs-version
|
||||
```
|
||||
|
||||
### SceneCmd
|
||||
@@ -557,7 +565,7 @@ gobs-cli projector list-monitors
|
||||
- defaults to current scene
|
||||
|
||||
```console
|
||||
gobs-cli project open
|
||||
gobs-cli projector open
|
||||
|
||||
gobs-cli projector open --monitor-index=1 "test_scene"
|
||||
|
||||
|
||||
@@ -35,13 +35,13 @@ tasks:
|
||||
build-windows:
|
||||
desc: Build the gobs-cli project for Windows
|
||||
cmds:
|
||||
- GOOS=windows GOARCH=amd64 go build -o {{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe
|
||||
- GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.version=debug'" -o {{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe
|
||||
internal: true
|
||||
|
||||
build-linux:
|
||||
desc: Build the gobs-cli project for Linux
|
||||
cmds:
|
||||
- GOOS=linux GOARCH=amd64 go build -o {{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64
|
||||
- GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.version=debug'" -o {{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64
|
||||
internal: true
|
||||
|
||||
test:
|
||||
|
||||
11
main.go
11
main.go
@@ -18,10 +18,10 @@ import (
|
||||
|
||||
// ObsConfig holds the configuration for connecting to the OBS WebSocket server.
|
||||
type ObsConfig struct {
|
||||
Host string `flag:"host" help:"Host to connect to." default:"localhost" env:"OBS_HOST"`
|
||||
Port int `flag:"port" help:"Port to connect to." default:"4455" env:"OBS_PORT"`
|
||||
Password string `flag:"password" help:"Password for authentication." default:"" env:"OBS_PASSWORD"`
|
||||
Timeout int `flag:"timeout" help:"Timeout in seconds." default:"5" env:"OBS_TIMEOUT"`
|
||||
Host string `flag:"host" help:"Host to connect to." default:"localhost" env:"OBS_HOST" short:"H"`
|
||||
Port int `flag:"port" help:"Port to connect to." default:"4455" env:"OBS_PORT" short:"P"`
|
||||
Password string `flag:"password" help:"Password for authentication." default:"" env:"OBS_PASSWORD" short:"p"`
|
||||
Timeout int `flag:"timeout" help:"Timeout in seconds." default:"5" env:"OBS_TIMEOUT" short:"T"`
|
||||
}
|
||||
|
||||
// CLI is the main command line interface structure.
|
||||
@@ -30,8 +30,9 @@ type CLI struct {
|
||||
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
||||
|
||||
Man mangokong.ManFlag `help:"Print man page."`
|
||||
Version VersionFlag `help:"Print gobs-cli version information and quit" name:"version" short:"v"`
|
||||
|
||||
Version VersionCmd `help:"Show version." cmd:"" aliases:"v"`
|
||||
ObsVersion ObsVersionCmd `help:"Print OBS client and websocket version." cmd:"" aliases:"v"`
|
||||
Scene SceneCmd `help:"Manage scenes." cmd:"" aliases:"sc"`
|
||||
Sceneitem SceneItemCmd `help:"Manage scene items." cmd:"" aliases:"si"`
|
||||
Group GroupCmd `help:"Manage groups." cmd:"" aliases:"g"`
|
||||
|
||||
26
version.go
26
version.go
@@ -2,13 +2,33 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
// VersionCmd handles the version command.
|
||||
type VersionCmd struct{} // size = 0x0
|
||||
var version = "unknown"
|
||||
|
||||
// VersionFlag is a custom flag type for displaying version information.
|
||||
type VersionFlag string
|
||||
|
||||
// Decode implements the kong.Flag interface for VersionFlag.
|
||||
func (v VersionFlag) Decode(_ *kong.DecodeContext) error { return nil }
|
||||
|
||||
// IsBool implements the kong.Flag interface for VersionFlag.
|
||||
func (v VersionFlag) IsBool() bool { return true }
|
||||
|
||||
// BeforeApply implements the kong.Flag interface for VersionFlag.
|
||||
func (v VersionFlag) BeforeApply(app *kong.Kong, _ kong.Vars) error { // nolint: unparam
|
||||
fmt.Printf("gobs-cli version: %s\n", version)
|
||||
app.Exit(0) // Exit the application after printing the version
|
||||
return nil
|
||||
}
|
||||
|
||||
// ObsVersionCmd handles the version command.
|
||||
type ObsVersionCmd struct{} // size = 0x0
|
||||
|
||||
// Run executes the command to get the OBS client version.
|
||||
func (cmd *VersionCmd) Run(ctx *context) error {
|
||||
func (cmd *ObsVersionCmd) Run(ctx *context) error {
|
||||
version, err := ctx.Client.General.GetVersion()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestVersion(t *testing.T) {
|
||||
Out: &out,
|
||||
}
|
||||
|
||||
cmd := &VersionCmd{}
|
||||
cmd := &ObsVersionCmd{}
|
||||
err := cmd.Run(context)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get version: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user