2026-01-30 00:22:47 +00:00
|
|
|
package gocmd
|
|
|
|
|
|
|
|
|
|
import (
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
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>
2026-01-30 21:55:55 +00:00
|
|
|
"errors"
|
2026-01-30 00:22:47 +00:00
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
|
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-30 00:22:47 +00:00
|
|
|
)
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
var (
|
|
|
|
|
installVerbose bool
|
|
|
|
|
installNoCgo bool
|
|
|
|
|
)
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
func addGoInstallCommand(parent *cobra.Command) {
|
|
|
|
|
installCmd := &cobra.Command{
|
|
|
|
|
Use: "install [path]",
|
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.go.install.short"),
|
|
|
|
|
Long: i18n.T("cmd.go.install.long"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
// Get install path from args or default to current dir
|
|
|
|
|
installPath := "./..."
|
|
|
|
|
if len(args) > 0 {
|
|
|
|
|
installPath = args[0]
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// Detect if we're in a module with cmd/ subdirectories or a root main.go
|
|
|
|
|
if installPath == "./..." {
|
|
|
|
|
if _, err := os.Stat("core.go"); err == nil {
|
|
|
|
|
installPath = "."
|
|
|
|
|
} else if entries, err := os.ReadDir("cmd"); err == nil && len(entries) > 0 {
|
|
|
|
|
installPath = "./cmd/..."
|
|
|
|
|
} else if _, err := os.Stat("main.go"); err == nil {
|
|
|
|
|
installPath = "."
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
refactor(i18n): consolidate duplicate translation keys into common section
Add common.* keys for reusable translations:
- common.label.* - UI labels (error, done, status, version, etc.)
- common.status.* - status words (running, stopped, dirty, synced)
- common.error.* - error messages (failed, not_found, working_dir)
- common.flag.* - CLI flag descriptions (registry, verbose, etc.)
- common.count.* - count templates (failed, passed, skipped)
- common.result.* - result messages (all_passed, no_issues)
- common.progress.* - progress messages (running, checking)
- common.hint.* - help hints (install_with, fix_deps)
Update all cmd/* files to use common keys instead of duplicated
command-specific keys. Reduces translation maintenance burden
and ensures consistency across the CLI.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:32:25 +00:00
|
|
|
fmt.Printf("%s %s\n", dimStyle.Render(i18n.T("common.label.install")), i18n.T("common.status.installing"))
|
|
|
|
|
fmt.Printf(" %s %s\n", dimStyle.Render(i18n.T("common.label.path")), installPath)
|
2026-01-30 00:47:54 +00:00
|
|
|
if installNoCgo {
|
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", dimStyle.Render(i18n.T("cmd.go.install.cgo_label")), i18n.T("cmd.go.install.cgo_disabled"))
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
cmdArgs := []string{"install"}
|
|
|
|
|
if installVerbose {
|
|
|
|
|
cmdArgs = append(cmdArgs, "-v")
|
|
|
|
|
}
|
|
|
|
|
cmdArgs = append(cmdArgs, installPath)
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
execCmd := exec.Command("go", cmdArgs...)
|
|
|
|
|
if installNoCgo {
|
|
|
|
|
execCmd.Env = append(os.Environ(), "CGO_ENABLED=0")
|
|
|
|
|
}
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
if err := execCmd.Run(); err != nil {
|
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", errorStyle.Render(i18n.T("cmd.go.install.failed")))
|
2026-01-30 00:47:54 +00:00
|
|
|
return err
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
// Show where it was installed
|
|
|
|
|
gopath := os.Getenv("GOPATH")
|
|
|
|
|
if gopath == "" {
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
gopath = filepath.Join(home, "go")
|
|
|
|
|
}
|
|
|
|
|
binDir := filepath.Join(gopath, "bin")
|
|
|
|
|
|
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 %s\n", successStyle.Render(i18n.T("cmd.go.install.success")), i18n.T("cmd.go.install.installed_to", map[string]interface{}{"Path": binDir}))
|
2026-01-30 00:47:54 +00:00
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
refactor(i18n): consolidate duplicate translation keys into common section
Add common.* keys for reusable translations:
- common.label.* - UI labels (error, done, status, version, etc.)
- common.status.* - status words (running, stopped, dirty, synced)
- common.error.* - error messages (failed, not_found, working_dir)
- common.flag.* - CLI flag descriptions (registry, verbose, etc.)
- common.count.* - count templates (failed, passed, skipped)
- common.result.* - result messages (all_passed, no_issues)
- common.progress.* - progress messages (running, checking)
- common.hint.* - help hints (install_with, fix_deps)
Update all cmd/* files to use common keys instead of duplicated
command-specific keys. Reduces translation maintenance burden
and ensures consistency across the CLI.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:32:25 +00:00
|
|
|
installCmd.Flags().BoolVarP(&installVerbose, "verbose", "v", false, i18n.T("common.flag.verbose"))
|
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
|
|
|
installCmd.Flags().BoolVar(&installNoCgo, "no-cgo", false, i18n.T("cmd.go.install.flag.no_cgo"))
|
2026-01-30 00:47:54 +00:00
|
|
|
|
|
|
|
|
parent.AddCommand(installCmd)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
func addGoModCommand(parent *cobra.Command) {
|
|
|
|
|
modCmd := &cobra.Command{
|
|
|
|
|
Use: "mod",
|
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.go.mod.short"),
|
|
|
|
|
Long: i18n.T("cmd.go.mod.long"),
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// tidy
|
2026-01-30 00:47:54 +00:00
|
|
|
tidyCmd := &cobra.Command{
|
|
|
|
|
Use: "tidy",
|
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.go.mod.tidy.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "mod", "tidy")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// download
|
2026-01-30 00:47:54 +00:00
|
|
|
downloadCmd := &cobra.Command{
|
|
|
|
|
Use: "download",
|
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.go.mod.download.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "mod", "download")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// verify
|
2026-01-30 00:47:54 +00:00
|
|
|
verifyCmd := &cobra.Command{
|
|
|
|
|
Use: "verify",
|
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.go.mod.verify.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "mod", "verify")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// graph
|
2026-01-30 00:47:54 +00:00
|
|
|
graphCmd := &cobra.Command{
|
|
|
|
|
Use: "graph",
|
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.go.mod.graph.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "mod", "graph")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modCmd.AddCommand(tidyCmd)
|
|
|
|
|
modCmd.AddCommand(downloadCmd)
|
|
|
|
|
modCmd.AddCommand(verifyCmd)
|
|
|
|
|
modCmd.AddCommand(graphCmd)
|
|
|
|
|
parent.AddCommand(modCmd)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
func addGoWorkCommand(parent *cobra.Command) {
|
|
|
|
|
workCmd := &cobra.Command{
|
|
|
|
|
Use: "work",
|
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.go.work.short"),
|
|
|
|
|
Long: i18n.T("cmd.go.work.long"),
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// sync
|
2026-01-30 00:47:54 +00:00
|
|
|
syncCmd := &cobra.Command{
|
|
|
|
|
Use: "sync",
|
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.go.work.sync.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "work", "sync")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// init
|
2026-01-30 00:47:54 +00:00
|
|
|
initCmd := &cobra.Command{
|
|
|
|
|
Use: "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
|
|
|
Short: i18n.T("cmd.go.work.init.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
execCmd := exec.Command("go", "work", "init")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
if err := execCmd.Run(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
// Auto-add current module if go.mod exists
|
|
|
|
|
if _, err := os.Stat("go.mod"); err == nil {
|
|
|
|
|
execCmd = exec.Command("go", "work", "use", ".")
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-01-30 00:22:47 +00:00
|
|
|
|
|
|
|
|
// use
|
2026-01-30 00:47:54 +00:00
|
|
|
useCmd := &cobra.Command{
|
|
|
|
|
Use: "use [modules...]",
|
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.go.work.use.short"),
|
2026-01-30 00:47:54 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
|
// Auto-detect modules
|
|
|
|
|
modules := findGoModules(".")
|
|
|
|
|
if len(modules) == 0 {
|
refactor(cli): move commands from cmd/ to pkg/ with self-registration
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>
2026-01-30 21:55:55 +00:00
|
|
|
return errors.New(i18n.T("cmd.go.work.error.no_modules"))
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
2026-01-30 00:47:54 +00:00
|
|
|
for _, mod := range modules {
|
|
|
|
|
execCmd := exec.Command("go", "work", "use", mod)
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
if err := execCmd.Run(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
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.go.work.added", map[string]interface{}{"Module": mod}))
|
2026-01-30 00:47:54 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 00:47:54 +00:00
|
|
|
cmdArgs := append([]string{"work", "use"}, args...)
|
|
|
|
|
execCmd := exec.Command("go", cmdArgs...)
|
|
|
|
|
execCmd.Stdout = os.Stdout
|
|
|
|
|
execCmd.Stderr = os.Stderr
|
|
|
|
|
return execCmd.Run()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workCmd.AddCommand(syncCmd)
|
|
|
|
|
workCmd.AddCommand(initCmd)
|
|
|
|
|
workCmd.AddCommand(useCmd)
|
|
|
|
|
parent.AddCommand(workCmd)
|
2026-01-30 00:22:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func findGoModules(root string) []string {
|
|
|
|
|
var modules []string
|
|
|
|
|
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if info.Name() == "go.mod" && path != "go.mod" {
|
|
|
|
|
modules = append(modules, filepath.Dir(path))
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
return modules
|
|
|
|
|
}
|