feat: 增加命令行工具的干运行模式和输出目录选项

This commit is contained in:
Rogee
2025-09-10 14:30:16 +08:00
parent a714d4a3a9
commit 3b804b83da
5 changed files with 221 additions and 139 deletions

View File

@@ -5,20 +5,22 @@ import (
)
func CommandInit(root *cobra.Command) {
cmd := &cobra.Command{
Use: "new [project|module]",
Short: "new project/module",
}
cmd := &cobra.Command{
Use: "new [project|module]",
Short: "new project/module",
}
cmd.PersistentFlags().BoolP("force", "f", false, "Force init project if exists")
cmd.PersistentFlags().BoolP("force", "f", false, "Force overwrite existing files or directories")
cmd.PersistentFlags().Bool("dry-run", false, "Preview actions without writing files")
cmd.PersistentFlags().String("dir", ".", "Base directory for outputs")
cmds := []func(*cobra.Command){
CommandNewProject,
// deprecate CommandNewModule,
CommandNewProvider,
CommandNewEvent,
CommandNewJob,
}
cmds := []func(*cobra.Command){
CommandNewProject,
// deprecate CommandNewModule,
CommandNewProvider,
CommandNewEvent,
CommandNewJob,
}
for _, c := range cmds {
c(cmd)