feat: migrate to use cobra as cli dep

This commit is contained in:
2026-03-16 23:36:01 +00:00
parent f37548b56b
commit 9cf3ed6a5c
6 changed files with 262 additions and 40 deletions
+21 -13
View File
@@ -1,21 +1,29 @@
package cmd
import "miro/internal/output"
import "github.com/spf13/cobra"
// Run parses top-level CLI args and returns a process exit code.
// Run executes the miro CLI and returns a process exit code.
func Run(args []string) int {
if len(args) == 0 {
output.Println("unknown command")
rootCmd := newRootCommand()
rootCmd.SetArgs(args)
if err := rootCmd.Execute(); err != nil {
return 1
}
switch args[0] {
case "init":
return runInit(args[1:])
case "record":
return runRecord(args[1:])
default:
output.Printf("unknown command: %s\n", args[0])
return 1
}
return 0
}
func newRootCommand() *cobra.Command {
rootCmd := &cobra.Command{
Use: "miro",
Short: "A lean CLI E2E testing framework.",
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
}
rootCmd.AddCommand(newInitCommand(), newRecordCommand())
return rootCmd
}