Implements defence in depth through build variants - only compiled code
exists in the binary. Commands now self-register via cli.RegisterCommands()
in their init() functions, mirroring the i18n.RegisterLocales() pattern.
Structure changes:
- cmd/{ai,build,ci,dev,docs,doctor,go,php,pkg,sdk,setup,test,vm}/ → pkg/*/cmd_*.go
- cmd/core_dev.go, cmd/core_ci.go → cmd/variants/{full,ci,php,minimal}.go
- Added pkg/cli/commands.go with RegisterCommands API
- Updated pkg/cli/runtime.go to attach registered commands
Build variants:
- go build → full (21MB, all 13 command groups)
- go build -tags ci → ci (18MB, build/ci/sdk/doctor)
- go build -tags php → php (14MB, php/doctor)
- go build -tags minimal → minimal (11MB, doctor only)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
1.9 KiB
Go
78 lines
1.9 KiB
Go
package docs
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/host-uk/core/pkg/cli"
|
|
"github.com/host-uk/core/pkg/i18n"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Flag variable for list command
|
|
var docsListRegistryPath string
|
|
|
|
var docsListCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: i18n.T("cmd.docs.list.short"),
|
|
Long: i18n.T("cmd.docs.list.long"),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runDocsList(docsListRegistryPath)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
docsListCmd.Flags().StringVar(&docsListRegistryPath, "registry", "", i18n.T("common.flag.registry"))
|
|
}
|
|
|
|
func runDocsList(registryPath string) error {
|
|
reg, _, err := loadRegistry(registryPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("\n%-20s %-8s %-8s %-10s %s\n",
|
|
headerStyle.Render(i18n.T("common.label.repo")),
|
|
headerStyle.Render(i18n.T("cmd.docs.list.header.readme")),
|
|
headerStyle.Render(i18n.T("cmd.docs.list.header.claude")),
|
|
headerStyle.Render(i18n.T("cmd.docs.list.header.changelog")),
|
|
headerStyle.Render(i18n.T("cmd.docs.list.header.docs")),
|
|
)
|
|
fmt.Println(strings.Repeat("─", 70))
|
|
|
|
var withDocs, withoutDocs int
|
|
for _, repo := range reg.List() {
|
|
info := scanRepoDocs(repo)
|
|
|
|
readme := cli.CheckMark(info.Readme != "")
|
|
claude := cli.CheckMark(info.ClaudeMd != "")
|
|
changelog := cli.CheckMark(info.Changelog != "")
|
|
|
|
docsDir := cli.CheckMark(false)
|
|
if len(info.DocsFiles) > 0 {
|
|
docsDir = docsFoundStyle.Render(i18n.T("common.count.files", map[string]interface{}{"Count": len(info.DocsFiles)}))
|
|
}
|
|
|
|
fmt.Printf("%-20s %-8s %-8s %-10s %s\n",
|
|
repoNameStyle.Render(info.Name),
|
|
readme,
|
|
claude,
|
|
changelog,
|
|
docsDir,
|
|
)
|
|
|
|
if info.HasDocs {
|
|
withDocs++
|
|
} else {
|
|
withoutDocs++
|
|
}
|
|
}
|
|
|
|
fmt.Println()
|
|
fmt.Printf("%s %s\n",
|
|
cli.Label(i18n.T("common.label.coverage")),
|
|
i18n.T("cmd.docs.list.coverage_summary", map[string]interface{}{"WithDocs": withDocs, "WithoutDocs": withoutDocs}),
|
|
)
|
|
|
|
return nil
|
|
}
|