From d97db89866505bbd6f156d257ed8e786102cd3d2 Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 9 Mar 2026 12:05:13 +0000 Subject: [PATCH] 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 --- .idea/go-devops.iml | 9 +++++++++ .idea/misc.xml | 4 ++++ .idea/workspace.xml | 8 ++++++++ build/buildcmd/cmd_build.go | 19 +++++++++---------- cmd/deploy/cmd_ansible.go | 13 ++++++------- cmd/deploy/cmd_commands.go | 3 +-- cmd/deploy/cmd_deploy.go | 33 ++++++++++++++++----------------- cmd/prod/cmd_commands.go | 3 +-- cmd/prod/cmd_dns.go | 15 +++++++-------- cmd/prod/cmd_lb.go | 11 +++++------ cmd/prod/cmd_prod.go | 4 ++-- cmd/prod/cmd_setup.go | 5 ++--- cmd/prod/cmd_ssh.go | 7 +++---- cmd/prod/cmd_status.go | 5 ++--- cmd/sdk/cmd.go | 13 ++++++------- cmd/setup/cmd_ci.go | 5 ++--- cmd/setup/cmd_commands.go | 3 +-- cmd/setup/cmd_github.go | 7 +++---- cmd/setup/cmd_setup.go | 7 +++---- cmd/vm/cmd_container.go | 32 ++++++++++++++++---------------- cmd/vm/cmd_templates.go | 20 ++++++++++---------- cmd/vm/cmd_vm.go | 5 ++--- 22 files changed, 118 insertions(+), 113 deletions(-) create mode 100644 .idea/go-devops.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/go-devops.iml b/.idea/go-devops.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/go-devops.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..90dee70 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + {} + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..dabf7ae --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,8 @@ + + + { + "keyToString": { + "settings.editor.selected.configurable": "vcs.Git" + } +} + \ No newline at end of file diff --git a/build/buildcmd/cmd_build.go b/build/buildcmd/cmd_build.go index d5e308d..294c99a 100644 --- a/build/buildcmd/cmd_build.go +++ b/build/buildcmd/cmd_build.go @@ -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) diff --git a/cmd/deploy/cmd_ansible.go b/cmd/deploy/cmd_ansible.go index 710deec..56f0610 100644 --- a/cmd/deploy/cmd_ansible.go +++ b/cmd/deploy/cmd_ansible.go @@ -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 ", 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 ", 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)) diff --git a/cmd/deploy/cmd_commands.go b/cmd/deploy/cmd_commands.go index 4c2f79f..193865f 100644 --- a/cmd/deploy/cmd_commands.go +++ b/cmd/deploy/cmd_commands.go @@ -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) } diff --git a/cmd/deploy/cmd_deploy.go b/cmd/deploy/cmd_deploy.go index 2d1135b..b6c63fd 100644 --- a/cmd/deploy/cmd_deploy.go +++ b/cmd/deploy/cmd_deploy.go @@ -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 [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") diff --git a/cmd/prod/cmd_commands.go b/cmd/prod/cmd_commands.go index 65f01ea..1ecb3c8 100644 --- a/cmd/prod/cmd_commands.go +++ b/cmd/prod/cmd_commands.go @@ -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) } diff --git a/cmd/prod/cmd_dns.go b/cmd/prod/cmd_dns.go index 2bb15a7..4f362d4 100644 --- a/cmd/prod/cmd_dns.go +++ b/cmd/prod/cmd_dns.go @@ -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 ", 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 diff --git a/cmd/prod/cmd_lb.go b/cmd/prod/cmd_lb.go index 518ea5d..0c6c935 100644 --- a/cmd/prod/cmd_lb.go +++ b/cmd/prod/cmd_lb.go @@ -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 diff --git a/cmd/prod/cmd_prod.go b/cmd/prod/cmd_prod.go index 6489654..f00b364 100644 --- a/cmd/prod/cmd_prod.go +++ b/cmd/prod/cmd_prod.go @@ -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. diff --git a/cmd/prod/cmd_setup.go b/cmd/prod/cmd_setup.go index 5ff3ad2..3e54442 100644 --- a/cmd/prod/cmd_setup.go +++ b/cmd/prod/cmd_setup.go @@ -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 diff --git a/cmd/prod/cmd_ssh.go b/cmd/prod/cmd_ssh.go index f2a37fe..7760836 100644 --- a/cmd/prod/cmd_ssh.go +++ b/cmd/prod/cmd_ssh.go @@ -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 ", 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 diff --git a/cmd/prod/cmd_status.go b/cmd/prod/cmd_status.go index 63eff06..b69b66c 100644 --- a/cmd/prod/cmd_status.go +++ b/cmd/prod/cmd_status.go @@ -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 diff --git a/cmd/sdk/cmd.go b/cmd/sdk/cmd.go index 051b0e1..e20caec 100644 --- a/cmd/sdk/cmd.go +++ b/cmd/sdk/cmd.go @@ -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")) diff --git a/cmd/setup/cmd_ci.go b/cmd/setup/cmd_ci.go index 76d7881..c4ea460 100644 --- a/cmd/setup/cmd_ci.go +++ b/cmd/setup/cmd_ci.go @@ -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 diff --git a/cmd/setup/cmd_commands.go b/cmd/setup/cmd_commands.go index 0d179fb..0f61918 100644 --- a/cmd/setup/cmd_commands.go +++ b/cmd/setup/cmd_commands.go @@ -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) } diff --git a/cmd/setup/cmd_github.go b/cmd/setup/cmd_github.go index 6fef6ff..2664e11 100644 --- a/cmd/setup/cmd_github.go +++ b/cmd/setup/cmd_github.go @@ -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() }, } diff --git a/cmd/setup/cmd_setup.go b/cmd/setup/cmd_setup.go index 647d97b..d933cb4 100644 --- a/cmd/setup/cmd_setup.go +++ b/cmd/setup/cmd_setup.go @@ -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) diff --git a/cmd/vm/cmd_container.go b/cmd/vm/cmd_container.go index 464eb14..5f6d524 100644 --- a/cmd/vm/cmd_container.go +++ b/cmd/vm/cmd_container.go @@ -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 ", 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 ", 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 [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")) } diff --git a/cmd/vm/cmd_templates.go b/cmd/vm/cmd_templates.go index 2b220b3..cfbb4b7 100644 --- a/cmd/vm/cmd_templates.go +++ b/cmd/vm/cmd_templates.go @@ -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 ", 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 ", 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")) } diff --git a/cmd/vm/cmd_vm.go b/cmd/vm/cmd_vm.go index 237e031..d5a00fb 100644 --- a/cmd/vm/cmd_vm.go +++ b/cmd/vm/cmd_vm.go @@ -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"),