mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-06-10 05:30:34 +01:00
add VersionFlag to CLI struct
upd VersionCmd struct
This commit is contained in:
parent
666b4cf744
commit
95ebb2afb6
3
main.go
3
main.go
@ -30,8 +30,9 @@ type CLI struct {
|
|||||||
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
ObsConfig `embed:"" help:"OBS WebSocket configuration."`
|
||||||
|
|
||||||
Man mangokong.ManFlag `help:"Print man page."`
|
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"`
|
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"`
|
||||||
Group GroupCmd `help:"Manage groups." cmd:"" aliases:"g"`
|
Group GroupCmd `help:"Manage groups." cmd:"" aliases:"g"`
|
||||||
|
26
version.go
26
version.go
@ -2,13 +2,33 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/alecthomas/kong"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VersionCmd handles the version command.
|
var version = "unknown"
|
||||||
type VersionCmd struct{} // size = 0x0
|
|
||||||
|
// 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
|
||||||
|
|
||||||
// Run executes the command to get the OBS client version.
|
// 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()
|
version, err := ctx.Client.General.GetVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user