mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-04-17 22:53:36 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c653047c66 | |||
| 30fabe8cfc | |||
| 8cf969c906 | |||
| 3540c60c4b | |||
| b2c5980b4a | |||
| da1ef9f993 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -26,5 +26,15 @@ go.work
|
||||
|
||||
# End of gignore: github.com/onyx-and-iris/gignore
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.envrc
|
||||
|
||||
# Man pages
|
||||
gobs-cli.1
|
||||
|
||||
# Config files
|
||||
config.yaml
|
||||
|
||||
# Test files
|
||||
*_test.go
|
||||
@@ -5,6 +5,13 @@ 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.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
|
||||
|
||||
20
README.md
20
README.md
@@ -22,17 +22,19 @@ gobs-cli --host=localhost --port=4455 --password=<websocket password> --help
|
||||
|
||||
#### Environment Variables
|
||||
|
||||
Load connection details from your environment:
|
||||
Store and load environment variables from:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
- A `.env` file in the cwd
|
||||
- $XDG_CONFIG_HOME / gobs-cli / config.env (see [os.UserConfigDir][userconfigdir])
|
||||
|
||||
export OBS_HOST=localhost
|
||||
export OBS_PORT=4455
|
||||
export OBS_PASSWORD=<websocket password>
|
||||
export OBS_TIMEOUT=5
|
||||
```env
|
||||
OBS_HOST=localhost
|
||||
OBS_PORT=4455
|
||||
OBS_PASSWORD=<websocket password>
|
||||
OBS_TIMEOUT=5
|
||||
```
|
||||
|
||||
|
||||
## Commands
|
||||
|
||||
### VersionCmd
|
||||
@@ -433,4 +435,6 @@ gobs-cli virtualcam toggle
|
||||
|
||||
```console
|
||||
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'
|
||||
|
||||
includes:
|
||||
man: Taskfile.man.yaml
|
||||
|
||||
vars:
|
||||
PROGRAM: gobs-cli
|
||||
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||
@@ -50,8 +53,3 @@ tasks:
|
||||
desc: Clean the build artifacts
|
||||
cmds:
|
||||
- '{{.SHELL}} rm -r {{.BIN_DIR}}'
|
||||
|
||||
manfile:
|
||||
desc: Generate manfile
|
||||
cmds:
|
||||
- go run . --man > manfile
|
||||
|
||||
2
go.mod
2
go.mod
@@ -6,12 +6,14 @@ require (
|
||||
github.com/alecthomas/kong v1.10.0
|
||||
github.com/alecthomas/mango-kong v0.1.0
|
||||
github.com/andreykaipov/goobs v1.5.6
|
||||
github.com/titusjaka/kong-dotenv-go v0.1.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // 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/mmcloughlin/profile v0.1.1 // indirect
|
||||
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@@ -18,6 +18,8 @@ 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/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
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/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mmcloughlin/profile v0.1.1 h1:jhDmAqPyebOsVDOCICJoINoLb/AnLBaUw58nFzxWS2w=
|
||||
@@ -32,5 +34,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
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/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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
11
main.go
11
main.go
@@ -7,11 +7,13 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
mangokong "github.com/alecthomas/mango-kong"
|
||||
"github.com/andreykaipov/goobs"
|
||||
kongdotenv "github.com/titusjaka/kong-dotenv-go"
|
||||
)
|
||||
|
||||
// ObsConfig holds the configuration for connecting to the OBS WebSocket server.
|
||||
@@ -49,11 +51,18 @@ type context struct {
|
||||
}
|
||||
|
||||
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(
|
||||
&cli,
|
||||
kong.Name("GOBS-CLI"),
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user