From d7cc9701334e21a1a39eb08a18156a9c29e3a98b Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 26 Mar 2026 11:59:17 -0700 Subject: [PATCH] Split CLI command stubs into separate files Move each command function from main.go into its own file (deploy.go, lifecycle.go, status.go, etc.) to enable parallel development by multiple workers without file conflicts. Co-Authored-By: Claude Opus 4.6 (1M context) --- cmd/mcp/adopt.go | 18 ++++ cmd/mcp/deploy.go | 20 ++++ cmd/mcp/lifecycle.go | 40 ++++++++ cmd/mcp/login.go | 17 ++++ cmd/mcp/main.go | 223 ++----------------------------------------- cmd/mcp/node.go | 43 +++++++++ cmd/mcp/service.go | 45 +++++++++ cmd/mcp/status.go | 38 ++++++++ cmd/mcp/sync.go | 17 ++++ cmd/mcp/transfer.go | 29 ++++++ 10 files changed, 275 insertions(+), 215 deletions(-) create mode 100644 cmd/mcp/adopt.go create mode 100644 cmd/mcp/deploy.go create mode 100644 cmd/mcp/lifecycle.go create mode 100644 cmd/mcp/login.go create mode 100644 cmd/mcp/node.go create mode 100644 cmd/mcp/service.go create mode 100644 cmd/mcp/status.go create mode 100644 cmd/mcp/sync.go create mode 100644 cmd/mcp/transfer.go diff --git a/cmd/mcp/adopt.go b/cmd/mcp/adopt.go new file mode 100644 index 0000000..8c48e74 --- /dev/null +++ b/cmd/mcp/adopt.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func adoptCmd() *cobra.Command { + return &cobra.Command{ + Use: "adopt ", + Short: "Adopt all -* containers into a service", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} diff --git a/cmd/mcp/deploy.go b/cmd/mcp/deploy.go new file mode 100644 index 0000000..f5edd1c --- /dev/null +++ b/cmd/mcp/deploy.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func deployCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "deploy [/]", + Short: "Deploy service from service definition", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + cmd.Flags().StringP("file", "f", "", "service definition file") + return cmd +} diff --git a/cmd/mcp/lifecycle.go b/cmd/mcp/lifecycle.go new file mode 100644 index 0000000..b5a2906 --- /dev/null +++ b/cmd/mcp/lifecycle.go @@ -0,0 +1,40 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func stopCmd() *cobra.Command { + return &cobra.Command{ + Use: "stop ", + Short: "Stop all components, set active=false", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} + +func startCmd() *cobra.Command { + return &cobra.Command{ + Use: "start ", + Short: "Start all components, set active=true", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} + +func restartCmd() *cobra.Command { + return &cobra.Command{ + Use: "restart ", + Short: "Restart all components", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} diff --git a/cmd/mcp/login.go b/cmd/mcp/login.go new file mode 100644 index 0000000..aefb021 --- /dev/null +++ b/cmd/mcp/login.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func loginCmd() *cobra.Command { + return &cobra.Command{ + Use: "login", + Short: "Authenticate to MCIAS, store token", + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} diff --git a/cmd/mcp/main.go b/cmd/mcp/main.go index aa56301..b4bbd83 100644 --- a/cmd/mcp/main.go +++ b/cmd/mcp/main.go @@ -20,7 +20,14 @@ func main() { } root.PersistentFlags().StringVarP(&cfgPath, "config", "c", "", "config file path") - root.AddCommand(versionCmd()) + root.AddCommand(&cobra.Command{ + Use: "version", + Short: "Print version", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(version) + }, + }) + root.AddCommand(loginCmd()) root.AddCommand(deployCmd()) root.AddCommand(stopCmd()) @@ -41,217 +48,3 @@ func main() { os.Exit(1) } } - -func versionCmd() *cobra.Command { - return &cobra.Command{ - Use: "version", - Short: "Print version", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version) - }, - } -} - -func loginCmd() *cobra.Command { - return &cobra.Command{ - Use: "login", - Short: "Authenticate to MCIAS, store token", - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func deployCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "deploy [/]", - Short: "Deploy service from service definition", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - cmd.Flags().StringP("file", "f", "", "service definition file") - return cmd -} - -func stopCmd() *cobra.Command { - return &cobra.Command{ - Use: "stop ", - Short: "Stop all components, set active=false", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func startCmd() *cobra.Command { - return &cobra.Command{ - Use: "start ", - Short: "Start all components, set active=true", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func restartCmd() *cobra.Command { - return &cobra.Command{ - Use: "restart ", - Short: "Restart all components", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func listCmd() *cobra.Command { - return &cobra.Command{ - Use: "list", - Short: "List services from all agents (registry, no runtime query)", - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func psCmd() *cobra.Command { - return &cobra.Command{ - Use: "ps", - Short: "Live check: query runtime on all agents", - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func statusCmd() *cobra.Command { - return &cobra.Command{ - Use: "status [service]", - Short: "Full picture: live query + drift + recent events", - Args: cobra.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func syncCmd() *cobra.Command { - return &cobra.Command{ - Use: "sync", - Short: "Push service definitions to agents (update desired state)", - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func adoptCmd() *cobra.Command { - return &cobra.Command{ - Use: "adopt ", - Short: "Adopt all -* containers into a service", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func serviceCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "service", - Short: "Service definition management", - } - - show := &cobra.Command{ - Use: "show ", - Short: "Print current spec from agent registry", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - - edit := &cobra.Command{ - Use: "edit ", - Short: "Open service definition in $EDITOR", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - - export := &cobra.Command{ - Use: "export ", - Short: "Write agent registry spec to local service file", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - export.Flags().StringP("file", "f", "", "output file path") - - cmd.AddCommand(show, edit, export) - return cmd -} - -func pushCmd() *cobra.Command { - return &cobra.Command{ - Use: "push [path]", - Short: "Copy a local file into /srv//[path]", - Args: cobra.RangeArgs(2, 3), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func pullCmd() *cobra.Command { - return &cobra.Command{ - Use: "pull [local-file]", - Short: "Copy a file from /srv// to local", - Args: cobra.RangeArgs(2, 3), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } -} - -func nodeCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "node", - Short: "Node management", - } - - list := &cobra.Command{ - Use: "list", - Short: "List registered nodes", - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - - add := &cobra.Command{ - Use: "add
", - Short: "Register a node", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - - remove := &cobra.Command{ - Use: "remove ", - Short: "Deregister a node", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("not implemented") - }, - } - - cmd.AddCommand(list, add, remove) - return cmd -} diff --git a/cmd/mcp/node.go b/cmd/mcp/node.go new file mode 100644 index 0000000..fb03ff5 --- /dev/null +++ b/cmd/mcp/node.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func nodeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "node", + Short: "Node management", + } + + list := &cobra.Command{ + Use: "list", + Short: "List registered nodes", + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + + add := &cobra.Command{ + Use: "add
", + Short: "Register a node", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + + remove := &cobra.Command{ + Use: "remove ", + Short: "Deregister a node", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + + cmd.AddCommand(list, add, remove) + return cmd +} diff --git a/cmd/mcp/service.go b/cmd/mcp/service.go new file mode 100644 index 0000000..76565ae --- /dev/null +++ b/cmd/mcp/service.go @@ -0,0 +1,45 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func serviceCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "service", + Short: "Service definition management", + } + + show := &cobra.Command{ + Use: "show ", + Short: "Print current spec from agent registry", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + + edit := &cobra.Command{ + Use: "edit ", + Short: "Open service definition in $EDITOR", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + + export := &cobra.Command{ + Use: "export ", + Short: "Write agent registry spec to local service file", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } + export.Flags().StringP("file", "f", "", "output file path") + + cmd.AddCommand(show, edit, export) + return cmd +} diff --git a/cmd/mcp/status.go b/cmd/mcp/status.go new file mode 100644 index 0000000..6679aa7 --- /dev/null +++ b/cmd/mcp/status.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func listCmd() *cobra.Command { + return &cobra.Command{ + Use: "list", + Short: "List services from all agents (registry, no runtime query)", + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} + +func psCmd() *cobra.Command { + return &cobra.Command{ + Use: "ps", + Short: "Live check: query runtime on all agents", + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} + +func statusCmd() *cobra.Command { + return &cobra.Command{ + Use: "status [service]", + Short: "Full picture: live query + drift + recent events", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} diff --git a/cmd/mcp/sync.go b/cmd/mcp/sync.go new file mode 100644 index 0000000..ce0e670 --- /dev/null +++ b/cmd/mcp/sync.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func syncCmd() *cobra.Command { + return &cobra.Command{ + Use: "sync", + Short: "Push service definitions to agents (update desired state)", + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} diff --git a/cmd/mcp/transfer.go b/cmd/mcp/transfer.go new file mode 100644 index 0000000..8699b64 --- /dev/null +++ b/cmd/mcp/transfer.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func pushCmd() *cobra.Command { + return &cobra.Command{ + Use: "push [path]", + Short: "Copy a local file into /srv//[path]", + Args: cobra.RangeArgs(2, 3), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +} + +func pullCmd() *cobra.Command { + return &cobra.Command{ + Use: "pull [local-file]", + Short: "Copy a file from /srv// to local", + Args: cobra.RangeArgs(2, 3), + RunE: func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("not implemented") + }, + } +}