framework1/framework/command/kernel.go

36 lines
895 B
Go
Raw Normal View History

2024-10-19 22:02:19 +08:00
package command
2024-10-22 17:06:36 +08:00
import (
"fmt"
"github.com/Superdanda/hade/framework/cobra"
"os"
"os/exec"
)
2024-10-19 22:02:19 +08:00
func AddKernelCommands(root *cobra.Command) {
2024-10-20 22:56:46 +08:00
root.AddCommand(initCronCommand())
2024-10-19 22:02:19 +08:00
// 挂载AppCommand命令
root.AddCommand(initAppCommand())
2024-10-20 22:56:46 +08:00
root.AddCommand(initEnvCommand())
2024-10-22 17:06:36 +08:00
root.AddCommand(initBuildCommand())
root.AddCommand(initDevCommand())
2024-10-23 12:52:17 +08:00
root.AddCommand(initProviderCommand())
root.AddCommand(initCmdCommand())
root.AddCommand(initMiddlewareCommand())
2024-10-23 13:19:58 +08:00
root.AddCommand(initNewCommand())
2024-10-23 17:00:42 +08:00
root.AddCommand(initSwaggerCommand())
2024-10-24 16:15:06 +08:00
root.AddCommand(initDeployCommand())
2024-10-27 17:54:21 +08:00
root.AddCommand(initDatabaseCommand())
2024-10-22 17:06:36 +08:00
}
// 封装通用的命令执行器
func runCommand(path string, args []string) error {
cmd := exec.Command(path, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("命令执行失败: %v", err)
}
return nil
2024-10-19 22:02:19 +08:00
}