8. TUI Dashboard & Custom Commands
GoForge's core/console package combines Cobra CLI commands, a colorized zerolog pretty logger, and a full-screen Bubble Tea TUI Dashboard.
8.1 Create a Custom Console Command (stats:report)
Scaffold a new Cobra command using goforge gen:command:
goforge gen:command stats:reportThis creates core/console/stats_report_cmd.go and registers it on rootCmd automatically. Replace its contents to connect to the database and report user and task counts:
package console
import (
"fmt"
"github.com/acme/taskforge/core/database"
_ "github.com/acme/taskforge/core/database/drivers"
"github.com/acme/taskforge/internal/services/auth"
"github.com/acme/taskforge/internal/services/task"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(statsReportCmd)
}
var statsReportCmd = &cobra.Command{
Use: "stats:report",
Short: "Print user and task summary counts",
RunE: func(cmd *cobra.Command, args []string) error {
db, err := database.Connect(loadedCfg.DB)
if err != nil {
return err
}
defer db.Close()
gormDB, err := db.GetGorm()
if err != nil {
return err
}
var users, totalTasks, doneTasks int64
gormDB.Model(&auth.User{}).Count(&users)
gormDB.Model(&task.Task{}).Count(&totalTasks)
gormDB.Model(&task.Task{}).Where("status = ?", "done").Count(&doneTasks)
Info(fmt.Sprintf("Users: %d | Tasks: %d (Done: %d)", users, totalTasks, doneTasks))
Success("Report complete")
return nil
},
}Run your custom command:
goforge app serve stats:report
# or directly via Go:
go run ./app stats:reportInvoking Custom Commands via goforge
goforge app exposes serve, which forwards all arguments to go run app/main.go. Run custom commands with goforge app serve stats:report (not goforge app run).
8.2 Using the Interactive TUI Dashboard
Start the servers in an interactive terminal:
goforge app serveGoForge automatically launches the Bubble Tea TUI Dashboard whenever:
LOG_TYPEisterminal(orboth) andLOG_FORMATislogstdinandstdoutare interactive TTYs (TERM != "dumb",CI == "")--no-tuiis not passed
Inside the TUI:
- Sidebar panels:
All logs,HTTP(live address, status, requests/routes/errors),gRPC(live address, status, requests/errors), andSystem. - Shortcuts:
Tab/←/→/h/lor1–9— switch panels↑/↓/j/k/PgUp/PgDn/g/G— scroll the 5,000-line log ring bufferf— toggle auto-followc— clear current panelm— toggle mouse captureq/Ctrl+C— graceful shutdown (second press force-quits)
For CI, Docker, or plain log streaming:
goforge app serve --no-tui8.3 Live Reload with Air
GoForge ships air.toml preconfigured to build ./app into tmp/main, ignore _test.go files, and send clean SIGINT interrupts:
air -c air.toml