diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-26 23:03:57 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-26 23:03:57 +0300 |
| commit | e26089b6fb7030e3ba8be314c37603453520d2d4 (patch) | |
| tree | 47daa60aef8ad5f878a0e7eb62879bf67f98cb98 /internal/timer/operations.go | |
| parent | 5580124aa9700fdd575d783ab525dceb395634b9 (diff) | |
feat: Add raw and rawm status options
This commit introduces two new options for the Status: Stopped
Elapsed Time: 0s command:
- 0: Displays the elapsed time in seconds.
- 0: Displays the elapsed time in minutes.
Unit tests have been added for both new functionalities, and the has been updated to reflect these changes. The status test has also been refactored to be more robust and less prone to flakiness by directly manipulating the timer state instead of relying on .
Diffstat (limited to 'internal/timer/operations.go')
| -rw-r--r-- | internal/timer/operations.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/timer/operations.go b/internal/timer/operations.go index 2b50e9e..6bb825d 100644 --- a/internal/timer/operations.go +++ b/internal/timer/operations.go @@ -74,6 +74,34 @@ func ResetTimer() (string, error) { return "Timer reset.", nil } +func GetRawStatus() (string, error) { + state, err := LoadState() + if err != nil { + return "", fmt.Errorf("error loading state: %w", err) + } + + elapsed := state.ElapsedTime + if state.Running { + elapsed += time.Since(state.StartTime) + } + + return fmt.Sprintf("%d", int(elapsed.Seconds())), nil +} + +func GetRawMinutesStatus() (string, error) { + state, err := LoadState() + if err != nil { + return "", fmt.Errorf("error loading state: %w", err) + } + + elapsed := state.ElapsedTime + if state.Running { + elapsed += time.Since(state.StartTime) + } + + return fmt.Sprintf("%d", int(elapsed.Minutes())), nil +} + func GetPromptStatus() (string, error) { state, err := LoadState() if err != nil { |
