refactor: replace all cobra imports with core/cli

19 files migrated from github.com/spf13/cobra to
forge.lthn.ai/core/cli/pkg/cli. All cmd/ and build/ packages
now use cli.Command exclusively. Zero direct cobra dependencies
remain in application code.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-09 12:05:13 +00:00
parent 3a995db1db
commit d97db89866
22 changed files with 118 additions and 113 deletions

9
.idea/go-devops.iml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
.idea/misc.xml generated Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KubernetesApiProvider">{}</component>
</project>

8
.idea/workspace.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;settings.editor.selected.configurable&quot;: &quot;vcs.Git&quot;
}
}</component>
</project>

View file

@ -6,7 +6,6 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-i18n"
"github.com/spf13/cobra"
)
func init() {
@ -58,19 +57,19 @@ var (
sdkDryRun bool
)
var buildCmd = &cobra.Command{
var buildCmd = &cli.Command{
Use: "build",
Short: i18n.T("cmd.build.short"),
Long: i18n.T("cmd.build.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runProjectBuild(cmd.Context(), buildType, ciMode, targets, outputDir, doArchive, doChecksum, configPath, format, push, imageName, noSign, notarize, verbose)
},
}
var fromPathCmd = &cobra.Command{
var fromPathCmd = &cli.Command{
Use: "from-path",
Short: i18n.T("cmd.build.from_path.short"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if fromPath == "" {
return errPathRequired
}
@ -78,10 +77,10 @@ var fromPathCmd = &cobra.Command{
},
}
var pwaCmd = &cobra.Command{
var pwaCmd = &cli.Command{
Use: "pwa",
Short: i18n.T("cmd.build.pwa.short"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if pwaURL == "" {
return errURLRequired
}
@ -89,11 +88,11 @@ var pwaCmd = &cobra.Command{
},
}
var sdkBuildCmd = &cobra.Command{
var sdkBuildCmd = &cli.Command{
Use: "sdk",
Short: i18n.T("cmd.build.sdk.short"),
Long: i18n.T("cmd.build.sdk.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runBuildSDK(sdkSpec, sdkLang, sdkVersion, sdkDryRun)
},
}
@ -137,7 +136,7 @@ func initBuildFlags() {
}
// AddBuildCommands registers the 'build' command and all subcommands.
func AddBuildCommands(root *cobra.Command) {
func AddBuildCommands(root *cli.Command) {
initBuildFlags()
AddReleaseCommand(buildCmd)
root.AddCommand(buildCmd)

View file

@ -10,7 +10,6 @@ import (
"forge.lthn.ai/core/go-ansible"
"forge.lthn.ai/core/cli/pkg/cli"
"github.com/spf13/cobra"
)
var (
@ -23,7 +22,7 @@ var (
ansibleCheck bool
)
var ansibleCmd = &cobra.Command{
var ansibleCmd = &cli.Command{
Use: "ansible <playbook>",
Short: "Run Ansible playbooks natively (no Python required)",
Long: `Execute Ansible playbooks using a pure Go implementation.
@ -44,11 +43,11 @@ Examples:
core deploy ansible playbooks/coolify/create.yml -i inventory/
core deploy ansible site.yml -l production
core deploy ansible deploy.yml -e "version=1.2.3" -e "env=prod"`,
Args: cobra.ExactArgs(1),
Args: cli.ExactArgs(1),
RunE: runAnsible,
}
var ansibleTestCmd = &cobra.Command{
var ansibleTestCmd = &cli.Command{
Use: "test <host>",
Short: "Test SSH connectivity to a host",
Long: `Test SSH connection and gather facts from a host.
@ -56,7 +55,7 @@ var ansibleTestCmd = &cobra.Command{
Examples:
core deploy ansible test linux.snider.dev -u claude -p claude
core deploy ansible test server.example.com -i ~/.ssh/id_rsa`,
Args: cobra.ExactArgs(1),
Args: cli.ExactArgs(1),
RunE: runAnsibleTest,
}
@ -88,7 +87,7 @@ func init() {
Cmd.AddCommand(ansibleCmd)
}
func runAnsible(cmd *cobra.Command, args []string) error {
func runAnsible(cmd *cli.Command, args []string) error {
playbookPath := args[0]
// Resolve playbook path
@ -229,7 +228,7 @@ func runAnsible(cmd *cobra.Command, args []string) error {
return nil
}
func runAnsibleTest(cmd *cobra.Command, args []string) error {
func runAnsibleTest(cmd *cli.Command, args []string) error {
host := args[0]
fmt.Printf("Testing SSH connection to %s...\n", cli.BoldStyle.Render(host))

View file

@ -2,7 +2,6 @@ package deploy
import (
"forge.lthn.ai/core/cli/pkg/cli"
"github.com/spf13/cobra"
)
func init() {
@ -10,6 +9,6 @@ func init() {
}
// AddDeployCommands registers the 'deploy' command and all subcommands.
func AddDeployCommands(root *cobra.Command) {
func AddDeployCommands(root *cli.Command) {
root.AddCommand(Cmd)
}

View file

@ -9,7 +9,6 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-devops/deploy/coolify"
"forge.lthn.ai/core/go-i18n"
"github.com/spf13/cobra"
)
var (
@ -19,53 +18,53 @@ var (
)
// Cmd is the root deploy command.
var Cmd = &cobra.Command{
var Cmd = &cli.Command{
Use: "deploy",
Short: i18n.T("cmd.deploy.short"),
Long: i18n.T("cmd.deploy.long"),
}
var serversCmd = &cobra.Command{
var serversCmd = &cli.Command{
Use: "servers",
Short: "List Coolify servers",
RunE: runListServers,
}
var projectsCmd = &cobra.Command{
var projectsCmd = &cli.Command{
Use: "projects",
Short: "List Coolify projects",
RunE: runListProjects,
}
var appsCmd = &cobra.Command{
var appsCmd = &cli.Command{
Use: "apps",
Short: "List Coolify applications",
RunE: runListApps,
}
var dbsCmd = &cobra.Command{
var dbsCmd = &cli.Command{
Use: "databases",
Short: "List Coolify databases",
Aliases: []string{"dbs", "db"},
RunE: runListDatabases,
}
var servicesCmd = &cobra.Command{
var servicesCmd = &cli.Command{
Use: "services",
Short: "List Coolify services",
RunE: runListServices,
}
var teamCmd = &cobra.Command{
var teamCmd = &cli.Command{
Use: "team",
Short: "Show current team info",
RunE: runTeam,
}
var callCmd = &cobra.Command{
var callCmd = &cli.Command{
Use: "call <operation> [params-json]",
Short: "Call any Coolify API operation",
Args: cobra.RangeArgs(1, 2),
Args: cli.RangeArgs(1, 2),
RunE: runCall,
}
@ -148,7 +147,7 @@ func printItem(item map[string]any) {
fmt.Println()
}
func runListServers(cmd *cobra.Command, args []string) error {
func runListServers(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -167,7 +166,7 @@ func runListServers(cmd *cobra.Command, args []string) error {
return outputResult(servers)
}
func runListProjects(cmd *cobra.Command, args []string) error {
func runListProjects(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -186,7 +185,7 @@ func runListProjects(cmd *cobra.Command, args []string) error {
return outputResult(projects)
}
func runListApps(cmd *cobra.Command, args []string) error {
func runListApps(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -205,7 +204,7 @@ func runListApps(cmd *cobra.Command, args []string) error {
return outputResult(apps)
}
func runListDatabases(cmd *cobra.Command, args []string) error {
func runListDatabases(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -224,7 +223,7 @@ func runListDatabases(cmd *cobra.Command, args []string) error {
return outputResult(dbs)
}
func runListServices(cmd *cobra.Command, args []string) error {
func runListServices(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -243,7 +242,7 @@ func runListServices(cmd *cobra.Command, args []string) error {
return outputResult(services)
}
func runTeam(cmd *cobra.Command, args []string) error {
func runTeam(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return err
@ -257,7 +256,7 @@ func runTeam(cmd *cobra.Command, args []string) error {
return outputResult(team)
}
func runCall(cmd *cobra.Command, args []string) error {
func runCall(cmd *cli.Command, args []string) error {
client, err := getClient()
if err != nil {
return cli.WrapVerb(err, "initialize", "client")

View file

@ -2,7 +2,6 @@ package prod
import (
"forge.lthn.ai/core/cli/pkg/cli"
"github.com/spf13/cobra"
)
func init() {
@ -10,6 +9,6 @@ func init() {
}
// AddProdCommands registers the 'prod' command and all subcommands.
func AddProdCommands(root *cobra.Command) {
func AddProdCommands(root *cli.Command) {
root.AddCommand(Cmd)
}

View file

@ -9,10 +9,9 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-infra"
"github.com/spf13/cobra"
)
var dnsCmd = &cobra.Command{
var dnsCmd = &cli.Command{
Use: "dns",
Short: "Manage DNS records via CloudNS",
Long: `View and manage DNS records for host.uk.com via CloudNS API.
@ -22,20 +21,20 @@ Requires:
CLOUDNS_AUTH_PASSWORD CloudNS auth password`,
}
var dnsListCmd = &cobra.Command{
var dnsListCmd = &cli.Command{
Use: "list [zone]",
Short: "List DNS records",
Args: cobra.MaximumNArgs(1),
Args: cli.MaximumNArgs(1),
RunE: runDNSList,
}
var dnsSetCmd = &cobra.Command{
var dnsSetCmd = &cli.Command{
Use: "set <host> <type> <value>",
Short: "Create or update a DNS record",
Long: `Create or update a DNS record. Example:
core prod dns set hermes.lb A 1.2.3.4
core prod dns set "*.host.uk.com" CNAME hermes.lb.host.uk.com`,
Args: cobra.ExactArgs(3),
Args: cli.ExactArgs(3),
RunE: runDNSSet,
}
@ -62,7 +61,7 @@ func getDNSClient() (*infra.CloudNSClient, error) {
return infra.NewCloudNSClient(authID, authPass), nil
}
func runDNSList(cmd *cobra.Command, args []string) error {
func runDNSList(cmd *cli.Command, args []string) error {
dns, err := getDNSClient()
if err != nil {
return err
@ -100,7 +99,7 @@ func runDNSList(cmd *cobra.Command, args []string) error {
return nil
}
func runDNSSet(cmd *cobra.Command, args []string) error {
func runDNSSet(cmd *cli.Command, args []string) error {
dns, err := getDNSClient()
if err != nil {
return err

View file

@ -9,10 +9,9 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-infra"
"github.com/spf13/cobra"
)
var lbCmd = &cobra.Command{
var lbCmd = &cli.Command{
Use: "lb",
Short: "Manage Hetzner load balancer",
Long: `View and manage the Hetzner Cloud managed load balancer.
@ -20,13 +19,13 @@ var lbCmd = &cobra.Command{
Requires: HCLOUD_TOKEN`,
}
var lbStatusCmd = &cobra.Command{
var lbStatusCmd = &cli.Command{
Use: "status",
Short: "Show load balancer status and target health",
RunE: runLBStatus,
}
var lbCreateCmd = &cobra.Command{
var lbCreateCmd = &cli.Command{
Use: "create",
Short: "Create load balancer from infra.yaml",
RunE: runLBCreate,
@ -45,7 +44,7 @@ func getHCloudClient() (*infra.HCloudClient, error) {
return infra.NewHCloudClient(token), nil
}
func runLBStatus(cmd *cobra.Command, args []string) error {
func runLBStatus(cmd *cli.Command, args []string) error {
hc, err := getHCloudClient()
if err != nil {
return err
@ -101,7 +100,7 @@ func runLBStatus(cmd *cobra.Command, args []string) error {
return nil
}
func runLBCreate(cmd *cobra.Command, args []string) error {
func runLBCreate(cmd *cli.Command, args []string) error {
cfg, _, err := loadConfig()
if err != nil {
return err

View file

@ -1,7 +1,7 @@
package prod
import (
"github.com/spf13/cobra"
"forge.lthn.ai/core/cli/pkg/cli"
)
var (
@ -9,7 +9,7 @@ var (
)
// Cmd is the root prod command.
var Cmd = &cobra.Command{
var Cmd = &cli.Command{
Use: "prod",
Short: "Production infrastructure management",
Long: `Manage the Host UK production infrastructure.

View file

@ -9,10 +9,9 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-infra"
"github.com/spf13/cobra"
)
var setupCmd = &cobra.Command{
var setupCmd = &cli.Command{
Use: "setup",
Short: "Phase 1: discover topology, create LB, configure DNS",
Long: `Run the Phase 1 foundation setup:
@ -41,7 +40,7 @@ func init() {
setupCmd.Flags().StringVar(&setupStep, "step", "", "Run a specific step only (discover, lb, dns)")
}
func runSetup(cmd *cobra.Command, args []string) error {
func runSetup(cmd *cli.Command, args []string) error {
cfg, cfgPath, err := loadConfig()
if err != nil {
return err

View file

@ -7,10 +7,9 @@ import (
"syscall"
"forge.lthn.ai/core/cli/pkg/cli"
"github.com/spf13/cobra"
)
var sshCmd = &cobra.Command{
var sshCmd = &cli.Command{
Use: "ssh <host>",
Short: "SSH into a production host",
Long: `Open an SSH session to a production host defined in infra.yaml.
@ -20,11 +19,11 @@ Examples:
core prod ssh de
core prod ssh de2
core prod ssh build`,
Args: cobra.ExactArgs(1),
Args: cli.ExactArgs(1),
RunE: runSSH,
}
func runSSH(cmd *cobra.Command, args []string) error {
func runSSH(cmd *cli.Command, args []string) error {
cfg, _, err := loadConfig()
if err != nil {
return err

View file

@ -11,10 +11,9 @@ import (
"forge.lthn.ai/core/go-ansible"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-infra"
"github.com/spf13/cobra"
)
var statusCmd = &cobra.Command{
var statusCmd = &cli.Command{
Use: "status",
Short: "Show production infrastructure health",
Long: `Check connectivity, services, and cluster health across all production hosts.
@ -40,7 +39,7 @@ type hostStatus struct {
Error error
}
func runStatus(cmd *cobra.Command, args []string) error {
func runStatus(cmd *cli.Command, args []string) error {
cfg, cfgPath, err := loadConfig()
if err != nil {
return err

View file

@ -15,7 +15,6 @@ import (
"forge.lthn.ai/core/go-devops/sdk"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-i18n"
"github.com/spf13/cobra"
)
func init() {
@ -30,7 +29,7 @@ var (
sdkDimStyle = cli.DimStyle
)
var sdkCmd = &cobra.Command{
var sdkCmd = &cli.Command{
Use: "sdk",
Short: i18n.T("cmd.sdk.short"),
Long: i18n.T("cmd.sdk.long"),
@ -39,28 +38,28 @@ var sdkCmd = &cobra.Command{
var diffBasePath string
var diffSpecPath string
var sdkDiffCmd = &cobra.Command{
var sdkDiffCmd = &cli.Command{
Use: "diff",
Short: i18n.T("cmd.sdk.diff.short"),
Long: i18n.T("cmd.sdk.diff.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runSDKDiff(diffBasePath, diffSpecPath)
},
}
var validateSpecPath string
var sdkValidateCmd = &cobra.Command{
var sdkValidateCmd = &cli.Command{
Use: "validate",
Short: i18n.T("cmd.sdk.validate.short"),
Long: i18n.T("cmd.sdk.validate.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runSDKValidate(validateSpecPath)
},
}
// AddSDKCommands registers the 'sdk' command and all subcommands.
func AddSDKCommands(root *cobra.Command) {
func AddSDKCommands(root *cli.Command) {
// sdk diff flags
sdkDiffCmd.Flags().StringVar(&diffBasePath, "base", "", i18n.T("cmd.sdk.diff.flag.base"))
sdkDiffCmd.Flags().StringVar(&diffSpecPath, "spec", "", i18n.T("cmd.sdk.diff.flag.spec"))

View file

@ -8,7 +8,6 @@ import (
"forge.lthn.ai/core/cli/pkg/cli"
coreio "forge.lthn.ai/core/go-io"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)
@ -76,7 +75,7 @@ var (
)
func init() {
ciCmd := &cobra.Command{
ciCmd := &cli.Command{
Use: "ci",
Short: "Output CI installation commands for core CLI",
Long: `Output installation commands for the core CLI in CI environments.
@ -119,7 +118,7 @@ Examples:
setupCmd.AddCommand(ciCmd)
}
func runSetupCI(cmd *cobra.Command, args []string) error {
func runSetupCI(cmd *cli.Command, args []string) error {
cfg := LoadCIConfig()
// Use flag version or config default

View file

@ -25,7 +25,6 @@ package setup
import (
"forge.lthn.ai/core/cli/pkg/cli"
"github.com/spf13/cobra"
)
func init() {
@ -33,6 +32,6 @@ func init() {
}
// AddSetupCommands registers the 'setup' command and all subcommands.
func AddSetupCommands(root *cobra.Command) {
func AddSetupCommands(root *cli.Command) {
AddSetupCommand(root)
}

View file

@ -26,7 +26,6 @@ import (
"forge.lthn.ai/core/go-i18n"
coreio "forge.lthn.ai/core/go-io"
"forge.lthn.ai/core/go-scm/repos"
"github.com/spf13/cobra"
)
// GitHub command flags
@ -43,13 +42,13 @@ var (
)
// addGitHubCommand adds the 'github' subcommand to the setup command.
func addGitHubCommand(parent *cobra.Command) {
ghCmd := &cobra.Command{
func addGitHubCommand(parent *cli.Command) {
ghCmd := &cli.Command{
Use: "github",
Aliases: []string{"gh"},
Short: i18n.T("cmd.setup.github.short"),
Long: i18n.T("cmd.setup.github.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runGitHubSetup()
},
}

View file

@ -4,7 +4,6 @@ package setup
import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-i18n"
"github.com/spf13/cobra"
)
// Style aliases from shared package
@ -33,11 +32,11 @@ var (
build bool
)
var setupCmd = &cobra.Command{
var setupCmd = &cli.Command{
Use: "setup",
Short: i18n.T("cmd.setup.short"),
Long: i18n.T("cmd.setup.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return runSetupOrchestrator(registryPath, only, dryRun, all, name, build)
},
}
@ -52,7 +51,7 @@ func initSetupFlags() {
}
// AddSetupCommand adds the 'setup' command to the given parent command.
func AddSetupCommand(root *cobra.Command) {
func AddSetupCommand(root *cli.Command) {
initSetupFlags()
addGitHubCommand(setupCmd)
root.AddCommand(setupCmd)

View file

@ -10,10 +10,10 @@ import (
"text/tabwriter"
"time"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-container"
"forge.lthn.ai/core/go-i18n"
"forge.lthn.ai/core/go-io"
"github.com/spf13/cobra"
)
var (
@ -27,12 +27,12 @@ var (
)
// addVMRunCommand adds the 'run' command under vm.
func addVMRunCommand(parent *cobra.Command) {
runCmd := &cobra.Command{
func addVMRunCommand(parent *cli.Command) {
runCmd := &cli.Command{
Use: "run [image]",
Short: i18n.T("cmd.vm.run.short"),
Long: i18n.T("cmd.vm.run.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
opts := container.RunOptions{
Name: runName,
Detach: runDetach,
@ -111,12 +111,12 @@ func runContainer(image, name string, detach bool, memory, cpus, sshPort int) er
var psAll bool
// addVMPsCommand adds the 'ps' command under vm.
func addVMPsCommand(parent *cobra.Command) {
psCmd := &cobra.Command{
func addVMPsCommand(parent *cli.Command) {
psCmd := &cli.Command{
Use: "ps",
Short: i18n.T("cmd.vm.ps.short"),
Long: i18n.T("cmd.vm.ps.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return listContainers(psAll)
},
}
@ -205,12 +205,12 @@ func formatDuration(d time.Duration) string {
}
// addVMStopCommand adds the 'stop' command under vm.
func addVMStopCommand(parent *cobra.Command) {
stopCmd := &cobra.Command{
func addVMStopCommand(parent *cli.Command) {
stopCmd := &cli.Command{
Use: "stop <container-id>",
Short: i18n.T("cmd.vm.stop.short"),
Long: i18n.T("cmd.vm.stop.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if len(args) == 0 {
return errors.New(i18n.T("cmd.vm.error.id_required"))
}
@ -272,12 +272,12 @@ func resolveContainerID(manager *container.LinuxKitManager, partialID string) (s
var logsFollow bool
// addVMLogsCommand adds the 'logs' command under vm.
func addVMLogsCommand(parent *cobra.Command) {
logsCmd := &cobra.Command{
func addVMLogsCommand(parent *cli.Command) {
logsCmd := &cli.Command{
Use: "logs <container-id>",
Short: i18n.T("cmd.vm.logs.short"),
Long: i18n.T("cmd.vm.logs.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if len(args) == 0 {
return errors.New(i18n.T("cmd.vm.error.id_required"))
}
@ -313,12 +313,12 @@ func viewLogs(id string, follow bool) error {
}
// addVMExecCommand adds the 'exec' command under vm.
func addVMExecCommand(parent *cobra.Command) {
execCmd := &cobra.Command{
func addVMExecCommand(parent *cli.Command) {
execCmd := &cli.Command{
Use: "exec <container-id> <command> [args...]",
Short: i18n.T("cmd.vm.exec.short"),
Long: i18n.T("cmd.vm.exec.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if len(args) < 2 {
return errors.New(i18n.T("cmd.vm.error.id_and_cmd_required"))
}

View file

@ -10,19 +10,19 @@ import (
"strings"
"text/tabwriter"
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-container"
"forge.lthn.ai/core/go-i18n"
"forge.lthn.ai/core/go-io"
"github.com/spf13/cobra"
)
// addVMTemplatesCommand adds the 'templates' command under vm.
func addVMTemplatesCommand(parent *cobra.Command) {
templatesCmd := &cobra.Command{
func addVMTemplatesCommand(parent *cli.Command) {
templatesCmd := &cli.Command{
Use: "templates",
Short: i18n.T("cmd.vm.templates.short"),
Long: i18n.T("cmd.vm.templates.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
return listTemplates()
},
}
@ -35,12 +35,12 @@ func addVMTemplatesCommand(parent *cobra.Command) {
}
// addTemplatesShowCommand adds the 'templates show' subcommand.
func addTemplatesShowCommand(parent *cobra.Command) {
showCmd := &cobra.Command{
func addTemplatesShowCommand(parent *cli.Command) {
showCmd := &cli.Command{
Use: "show <template-name>",
Short: i18n.T("cmd.vm.templates.show.short"),
Long: i18n.T("cmd.vm.templates.show.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if len(args) == 0 {
return errors.New(i18n.T("cmd.vm.error.template_required"))
}
@ -52,12 +52,12 @@ func addTemplatesShowCommand(parent *cobra.Command) {
}
// addTemplatesVarsCommand adds the 'templates vars' subcommand.
func addTemplatesVarsCommand(parent *cobra.Command) {
varsCmd := &cobra.Command{
func addTemplatesVarsCommand(parent *cli.Command) {
varsCmd := &cli.Command{
Use: "vars <template-name>",
Short: i18n.T("cmd.vm.templates.vars.short"),
Long: i18n.T("cmd.vm.templates.vars.long"),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cli.Command, args []string) error {
if len(args) == 0 {
return errors.New(i18n.T("cmd.vm.error.template_required"))
}

View file

@ -4,7 +4,6 @@ package vm
import (
"forge.lthn.ai/core/cli/pkg/cli"
"forge.lthn.ai/core/go-i18n"
"github.com/spf13/cobra"
)
func init() {
@ -26,8 +25,8 @@ var (
)
// AddVMCommands adds container-related commands under 'vm' to the CLI.
func AddVMCommands(root *cobra.Command) {
vmCmd := &cobra.Command{
func AddVMCommands(root *cli.Command) {
vmCmd := &cli.Command{
Use: "vm",
Short: i18n.T("cmd.vm.short"),
Long: i18n.T("cmd.vm.long"),