refactor(cli): restructure cmd packages into subdirectories
- Move CLI commands into subdirectories matching command hierarchy:
dev/, go/, php/, build/, ci/, sdk/, pkg/, vm/, docs/, setup/, doctor/, test/, ai/
- Create shared/ package for common styles and utilities
- Add new `core ai` root command with claude subcommand
- Update package declarations and imports across all files
- Create commands.go entry points for each package
- Remove GUI-related files (moved to core-gui repo)
This makes the filesystem structure match the CLI command structure,
improving context capture and code organization.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:02:43 +00:00
|
|
|
// Package testcmd provides test running commands.
|
|
|
|
|
//
|
|
|
|
|
// Note: Package named testcmd to avoid conflict with Go's test package.
|
|
|
|
|
package testcmd
|
2026-01-29 11:15:23 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
2026-01-30 00:22:47 +00:00
|
|
|
"github.com/host-uk/core/cmd/shared"
|
2026-01-29 11:15:23 +00:00
|
|
|
"github.com/leaanthony/clir"
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Style aliases from shared
|
2026-01-29 11:15:23 +00:00
|
|
|
var (
|
2026-01-30 00:22:47 +00:00
|
|
|
testHeaderStyle = shared.RepoNameStyle
|
|
|
|
|
testPassStyle = shared.SuccessStyle
|
|
|
|
|
testFailStyle = shared.ErrorStyle
|
|
|
|
|
testSkipStyle = shared.WarningStyle
|
|
|
|
|
testDimStyle = shared.DimStyle
|
|
|
|
|
)
|
2026-01-29 11:15:23 +00:00
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Coverage-specific styles
|
|
|
|
|
var (
|
2026-01-29 11:15:23 +00:00
|
|
|
testCovHighStyle = lipgloss.NewStyle().
|
|
|
|
|
Foreground(lipgloss.Color("#22c55e")) // green-500
|
|
|
|
|
|
|
|
|
|
testCovMedStyle = lipgloss.NewStyle().
|
|
|
|
|
Foreground(lipgloss.Color("#f59e0b")) // amber-500
|
|
|
|
|
|
|
|
|
|
testCovLowStyle = lipgloss.NewStyle().
|
|
|
|
|
Foreground(lipgloss.Color("#ef4444")) // red-500
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// AddTestCommand adds the 'test' command to the given parent command.
|
|
|
|
|
func AddTestCommand(parent *clir.Cli) {
|
|
|
|
|
var verbose bool
|
|
|
|
|
var coverage bool
|
|
|
|
|
var short bool
|
|
|
|
|
var pkg string
|
|
|
|
|
var run string
|
|
|
|
|
var race bool
|
|
|
|
|
var json bool
|
|
|
|
|
|
|
|
|
|
testCmd := parent.NewSubCommand("test", "Run tests with coverage")
|
|
|
|
|
testCmd.LongDescription("Runs Go tests with coverage reporting.\n\n" +
|
|
|
|
|
"Sets MACOSX_DEPLOYMENT_TARGET=26.0 to suppress linker warnings on macOS.\n\n" +
|
|
|
|
|
"Examples:\n" +
|
|
|
|
|
" core test # Run all tests with coverage summary\n" +
|
|
|
|
|
" core test --verbose # Show test output as it runs\n" +
|
|
|
|
|
" core test --coverage # Show detailed per-package coverage\n" +
|
|
|
|
|
" core test --pkg ./pkg/... # Test specific packages\n" +
|
|
|
|
|
" core test --run TestName # Run specific test by name\n" +
|
|
|
|
|
" core test --short # Skip long-running tests\n" +
|
|
|
|
|
" core test --race # Enable race detector\n" +
|
|
|
|
|
" core test --json # Output JSON for CI/agents")
|
|
|
|
|
|
|
|
|
|
testCmd.BoolFlag("verbose", "Show test output as it runs (-v)", &verbose)
|
|
|
|
|
testCmd.BoolFlag("coverage", "Show detailed per-package coverage", &coverage)
|
|
|
|
|
testCmd.BoolFlag("short", "Skip long-running tests (-short)", &short)
|
|
|
|
|
testCmd.StringFlag("pkg", "Package pattern to test (default: ./...)", &pkg)
|
|
|
|
|
testCmd.StringFlag("run", "Run only tests matching this regex (-run)", &run)
|
|
|
|
|
testCmd.BoolFlag("race", "Enable race detector (-race)", &race)
|
|
|
|
|
testCmd.BoolFlag("json", "Output JSON for CI/agents", &json)
|
|
|
|
|
|
|
|
|
|
testCmd.Action(func() error {
|
|
|
|
|
return runTest(verbose, coverage, short, pkg, run, race, json)
|
|
|
|
|
})
|
|
|
|
|
}
|