Skip to content

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:

bash
goforge gen:command stats:report

This 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:

go
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:

bash
goforge app serve stats:report
# or directly via Go:
go run ./app stats:report

Invoking 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:

bash
goforge app serve

GoForge automatically launches the Bubble Tea TUI Dashboard whenever:

  • LOG_TYPE is terminal (or both) and LOG_FORMAT is log
  • stdin and stdout are interactive TTYs (TERM != "dumb", CI == "")
  • --no-tui is not passed

Inside the TUI:

  • Sidebar panels: All logs, HTTP (live address, status, requests/routes/errors), gRPC (live address, status, requests/errors), and System.
  • Shortcuts:
    • Tab / ← / → / h / l or 1–9 — switch panels
    • ↑ / ↓ / j / k / PgUp / PgDn / g / G — scroll the 5,000-line log ring buffer
    • f — toggle auto-follow
    • c — clear current panel
    • m — toggle mouse capture
    • q / Ctrl+C — graceful shutdown (second press force-quits)

For CI, Docker, or plain log streaming:

bash
goforge app serve --no-tui

8.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:

bash
air -c air.toml

Next: 9. Testing & Docker Deployment →

Released under the Apache-2.0 License.