Compare commits

..

No commits in common. "89a5add7ad8bb984f6c364bf3c9583d1733bb39f" and "666b4cf7449b4070b175732f0e732f1dcb2ed7be" have entirely different histories.

5 changed files with 22 additions and 53 deletions

View File

@ -5,16 +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/),
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

View File

@ -35,13 +35,13 @@ tasks:
build-windows:
desc: Build the gobs-cli project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.version=debug'" -o {{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe
- GOOS=windows GOARCH=amd64 go build -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 -ldflags "-X 'main.version=debug'" -o {{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64
- GOOS=linux GOARCH=amd64 go build -o {{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64
internal: true
test:

View File

@ -30,9 +30,8 @@ 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"`
ObsVersion ObsVersionCmd `help:"Print OBS client and websocket version." cmd:"" aliases:"v"`
Version VersionCmd `help:"Show 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"`

View File

@ -2,33 +2,13 @@ package main
import (
"fmt"
"github.com/alecthomas/kong"
)
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 {
fmt.Println(version)
app.Exit(0) // Exit the application after printing the version
return nil
}
// ObsVersionCmd handles the version command.
type ObsVersionCmd struct{} // size = 0x0
// VersionCmd handles the version command.
type VersionCmd struct{} // size = 0x0
// Run executes the command to get the OBS client version.
func (cmd *ObsVersionCmd) Run(ctx *context) error {
func (cmd *VersionCmd) Run(ctx *context) error {
version, err := ctx.Client.General.GetVersion()
if err != nil {
return err

View File

@ -16,7 +16,7 @@ func TestVersion(t *testing.T) {
Out: &out,
}
cmd := &ObsVersionCmd{}
cmd := &VersionCmd{}
err := cmd.Run(context)
if err != nil {
t.Fatalf("Failed to get version: %v", err)