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 doctor provides environment check commands.
|
|
|
|
|
package doctor
|
2026-01-28 14:50:55 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2026-01-29 18:13:51 +00:00
|
|
|
"github.com/host-uk/core/cmd/shared"
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
2026-01-30 00:47:54 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-01-28 14:50:55 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Style aliases from shared
|
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
|
|
|
var (
|
|
|
|
|
successStyle = shared.SuccessStyle
|
|
|
|
|
errorStyle = shared.ErrorStyle
|
|
|
|
|
dimStyle = shared.DimStyle
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// Flag variable for doctor command
|
|
|
|
|
var doctorVerbose bool
|
2026-01-28 14:50:55 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
var doctorCmd = &cobra.Command{
|
|
|
|
|
Use: "doctor",
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
Short: i18n.T("cmd.doctor.short"),
|
|
|
|
|
Long: i18n.T("cmd.doctor.long"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
return runDoctor(doctorVerbose)
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-28 14:50:55 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
func init() {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
doctorCmd.Flags().BoolVar(&doctorVerbose, "verbose", false, i18n.T("cmd.doctor.verbose_flag"))
|
2026-01-28 14:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func runDoctor(verbose bool) error {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(i18n.T("cmd.doctor.checking"))
|
2026-01-28 14:50:55 +00:00
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
|
|
var passed, failed, optional int
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check required tools
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(i18n.T("cmd.doctor.required"))
|
|
|
|
|
for _, c := range requiredChecks() {
|
2026-01-28 14:50:55 +00:00
|
|
|
ok, version := runCheck(c)
|
|
|
|
|
if ok {
|
2026-01-30 01:09:03 +00:00
|
|
|
if verbose {
|
|
|
|
|
fmt.Println(shared.CheckResult(true, c.name, version))
|
2026-01-28 14:50:55 +00:00
|
|
|
} else {
|
2026-01-30 01:09:03 +00:00
|
|
|
fmt.Println(shared.CheckResult(true, c.name, ""))
|
2026-01-28 14:50:55 +00:00
|
|
|
}
|
|
|
|
|
passed++
|
|
|
|
|
} else {
|
2026-01-30 01:09:03 +00:00
|
|
|
fmt.Printf(" %s %s - %s\n", errorStyle.Render(shared.SymbolCross), c.name, c.description)
|
2026-01-28 14:50:55 +00:00
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check optional tools
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf("\n%s\n", i18n.T("cmd.doctor.optional"))
|
|
|
|
|
for _, c := range optionalChecks() {
|
2026-01-28 14:50:55 +00:00
|
|
|
ok, version := runCheck(c)
|
|
|
|
|
if ok {
|
2026-01-30 01:09:03 +00:00
|
|
|
if verbose {
|
|
|
|
|
fmt.Println(shared.CheckResult(true, c.name, version))
|
2026-01-28 14:50:55 +00:00
|
|
|
} else {
|
2026-01-30 01:09:03 +00:00
|
|
|
fmt.Println(shared.CheckResult(true, c.name, ""))
|
2026-01-28 14:50:55 +00:00
|
|
|
}
|
|
|
|
|
passed++
|
|
|
|
|
} else {
|
2026-01-30 01:09:03 +00:00
|
|
|
fmt.Printf(" %s %s - %s\n", dimStyle.Render(shared.SymbolSkip), c.name, dimStyle.Render(c.description))
|
2026-01-28 14:50:55 +00:00
|
|
|
optional++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:22:47 +00:00
|
|
|
// Check GitHub access
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf("\n%s\n", i18n.T("cmd.doctor.github"))
|
2026-01-28 14:50:55 +00:00
|
|
|
if checkGitHubSSH() {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(shared.CheckResult(true, i18n.T("cmd.doctor.ssh_found"), ""))
|
2026-01-28 14:50:55 +00:00
|
|
|
} else {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf(" %s %s\n", errorStyle.Render(shared.SymbolCross), i18n.T("cmd.doctor.ssh_missing"))
|
2026-01-28 14:50:55 +00:00
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if checkGitHubCLI() {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(shared.CheckResult(true, i18n.T("cmd.doctor.cli_auth"), ""))
|
2026-01-28 14:50:55 +00:00
|
|
|
} else {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf(" %s %s\n", errorStyle.Render(shared.SymbolCross), i18n.T("cmd.doctor.cli_auth_missing"))
|
2026-01-28 14:50:55 +00:00
|
|
|
failed++
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check workspace
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Printf("\n%s\n", i18n.T("cmd.doctor.workspace"))
|
2026-01-30 00:22:47 +00:00
|
|
|
checkWorkspace()
|
2026-01-28 14:50:55 +00:00
|
|
|
|
|
|
|
|
// Summary
|
|
|
|
|
fmt.Println()
|
|
|
|
|
if failed > 0 {
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(shared.Error(i18n.T("cmd.doctor.issues", map[string]interface{}{"Count": failed})))
|
|
|
|
|
fmt.Printf("\n%s\n", i18n.T("cmd.doctor.install_missing"))
|
2026-01-28 14:50:55 +00:00
|
|
|
printInstallInstructions()
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
return fmt.Errorf("%s", i18n.T("cmd.doctor.issues_error", map[string]interface{}{"Count": failed}))
|
2026-01-28 14:50:55 +00:00
|
|
|
}
|
|
|
|
|
|
feat(i18n): add translation keys to all CLI commands
Replace hardcoded strings with i18n.T() calls across all cmd/* packages:
- ai, build, ci, dev, docs, doctor, go, php, pkg, sdk, setup, test, vm
Adds 500+ translation keys to en.json for command descriptions,
flag descriptions, labels, messages, and error strings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:37:57 +00:00
|
|
|
fmt.Println(shared.Success(i18n.T("cmd.doctor.ready")))
|
2026-01-28 14:50:55 +00:00
|
|
|
return nil
|
|
|
|
|
}
|