From dd0bbfc0daa9e810ed60c0f37b8d39911bef8fa2 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 8 May 2025 00:47:15 +0100 Subject: [PATCH] add missing record status command add replaybuffer toggle to readme --- .golangci.yml | 3 +++ README.md | 6 ++++++ record.go | 34 +++++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 0843388..38acab0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,3 +50,6 @@ issues: exclude: # gosec: Duplicated errcheck checks - G104 + exclude-files: + # Exclude vendor directory + - main_test.go diff --git a/README.md b/README.md index 6993ee6..d496947 100644 --- a/README.md +++ b/README.md @@ -373,6 +373,12 @@ gobs-cli replaybuffer start gobs-cli replaybuffer stop ``` +- toggle: Toggle replay buffer. + +```console +gobs-cli replaybuffer toggle +``` + - status: Get replay buffer status. ```console diff --git a/record.go b/record.go index 68fabf2..6eeb741 100644 --- a/record.go +++ b/record.go @@ -6,11 +6,12 @@ import ( // RecordCmd handles the recording commands. type RecordCmd struct { - Start RecordStartCmd `cmd:"" help:"Start recording." aliases:"s"` - Stop RecordStopCmd `cmd:"" help:"Stop recording." aliases:"st"` - Toggle RecordToggleCmd `cmd:"" help:"Toggle recording." aliases:"tg"` - Pause RecordPauseCmd `cmd:"" help:"Pause recording." aliases:"p"` - Resume RecordResumeCmd `cmd:"" help:"Resume recording." aliases:"r"` + Start RecordStartCmd `cmd:"" help:"Start recording." aliases:"s"` + Stop RecordStopCmd `cmd:"" help:"Stop recording." aliases:"st"` + Toggle RecordToggleCmd `cmd:"" help:"Toggle recording." aliases:"tg"` + Status RecordStatusCmd `cmd:"" help:"Show recording status." aliases:"ss"` + Pause RecordPauseCmd `cmd:"" help:"Pause recording." aliases:"p"` + Resume RecordResumeCmd `cmd:"" help:"Resume recording." aliases:"r"` } // RecordStartCmd starts the recording. @@ -57,6 +58,29 @@ func (cmd *RecordToggleCmd) Run(ctx *context) error { return nil } +// RecordStatusCmd shows the recording status. +type RecordStatusCmd struct{} // size = 0x0 + +// Run executes the command to show recording status. +func (cmd *RecordStatusCmd) Run(ctx *context) error { + status, err := ctx.Client.Record.GetRecordStatus() + if err != nil { + return err + } + + if status.OutputActive { + if status.OutputPaused { + fmt.Fprintln(ctx.Out, "Recording is paused.") + } else { + fmt.Fprintln(ctx.Out, "Recording is in progress.") + } + } else { + fmt.Fprintln(ctx.Out, "Recording is not in progress.") + } + + return nil +} + // RecordPauseCmd pauses the recording. type RecordPauseCmd struct{} // size = 0x0