Skip to content

feat: add terminal progress indicators - #4

Merged
cmilesio merged 1 commit into
mainfrom
feat/terminal-progress
Aug 8, 2026
Merged

feat: add terminal progress indicators#4
cmilesio merged 1 commit into
mainfrom
feat/terminal-progress

Conversation

@cmilesio

@cmilesio cmilesio commented Aug 8, 2026

Copy link
Copy Markdown
Member

What

Add opt-in OSC 9;4 terminal progress support to the existing loader and progress lifecycles.

New API

console.Config gains one optional field:

// TerminalProgressEnabled permits or disables OSC 9;4 terminal-owned progress
// indicators for loaders and progress displays.
// Nil and false disable indicators; true still requires terminal output with
// ANSI support.
TerminalProgressEnabled *bool

No new loader or progress methods are required. Enabling the option augments the established APIs:

  • Loader.Start publishes indeterminate terminal activity.
  • Loader.Stop, Loader.Success, Loader.Warn, and Loader.Fail clear it.
  • Progress.Start publishes the current percentage, including a value set before start.
  • Progress.Set, Progress.Add, and Progress.Step update the terminal percentage.
  • Progress.Stop, Progress.Complete, and Progress.Fail clear it.

Example

package main

import "github.com/goforj/console"

func main() {
    terminalProgress := true
    commandConsole := console.New(console.Config{
        TerminalProgressEnabled: &terminalProgress,
    })

    loader := commandConsole.Loader("Loading project")
    if err := loader.Start(); err != nil {
        commandConsole.Error(err.Error())
        return
    }
    loader.Success("Project ready")

    progress := commandConsole.Progress(4, "Installing files")
    if err := progress.Start(); err != nil {
        commandConsole.Error(err.Error())
        return
    }
    progress.Add(1)
    progress.Step(3, "Finalizing installation")
    progress.Complete("Files installed")
}

Supporting terminal emulators decide whether progress appears in a tab, window edge, or operating-system taskbar. The option is independent of AnimationsEnabled, requires an ANSI-capable terminal, and never emits OSC sequences into redirected output. Console-wide ownership prevents concurrent lifecycles from clearing one another.

The README documents the capability, and focused coverage exercises loader and progress lifecycles, capability gating, percentage bounds, idempotence, and concurrent ownership.

Why

Terminal-owned progress makes long-running GoForj work visible without consuming console rows or requiring each application to implement escape protocols itself. Keeping it behind an explicit configuration option preserves existing output behavior for current consumers.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cmilesio
cmilesio merged commit a85d97d into main Aug 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants