@@ -36,30 +36,43 @@ import (
36
36
// code of external projects is not feasible within Kubebuilder’s current design.
37
37
func NewScaffoldCommand () * cobra.Command {
38
38
opts := internal.Generate {}
39
+
39
40
scaffoldCmd := & cobra.Command {
40
41
Use : "generate" ,
41
- Short : "Re-scaffold an existing Kuberbuilder project" ,
42
- Long : `It's an experimental feature that has the purpose of re-scaffolding the whole project from the scratch
43
- using the current version of KubeBuilder binary available.
44
- # make sure the PROJECT file is in the 'input-dir' argument, the default is the current directory.
45
- $ kubebuilder alpha generate --input-dir="./test" --output-dir="./my-output"
46
- Then we will re-scaffold the project by Kubebuilder in the directory specified by 'output-dir'.
47
- ` ,
42
+ Short : "Re-scaffold a Kubebuilder project from its PROJECT file" ,
43
+ Long : `The 'generate' command re-creates a Kubebuilder project scaffold based on the configuration
44
+ defined in the PROJECT file, using the latest installed Kubebuilder version and plugins.
45
+
46
+ This is helpful for migrating projects to a newer Kubebuilder layout or plugin version (e.g., v3 to v4)
47
+ as update your project from any previous version to the current one.
48
+
49
+ If no output directory is provided, the current working directory will be cleaned (except .git and PROJECT).` ,
50
+ Example : `
51
+ # **WARNING**(will delete all files to allow the re-scaffold except .git and PROJECT)
52
+ # Re-scaffold the project in-place
53
+ kubebuilder alpha generate
54
+
55
+ # Re-scaffold the project from ./test into ./my-output
56
+ kubebuilder alpha generate --input-dir="./path/to/project" --output-dir="./my-output"
57
+ ` ,
48
58
PreRunE : func (_ * cobra.Command , _ []string ) error {
49
59
return opts .Validate ()
50
60
},
51
61
Run : func (_ * cobra.Command , _ []string ) {
52
62
if err := opts .Generate (); err != nil {
53
- log .Fatalf ("Failed to command %s" , err )
63
+ log .Fatalf ("failed to generate project: %s" , err )
54
64
}
55
65
},
56
66
}
67
+
57
68
scaffoldCmd .Flags ().StringVar (& opts .InputDir , "input-dir" , "" ,
58
- "Specifies the full path to a Kubebuilder project file. If not provided, " +
59
- "the current working directory is used." )
69
+ "Path to the directory containing the PROJECT file. " +
70
+ "Defaults to the current working directory. WARNING: delete existing files (except .git and PROJECT)." )
71
+
60
72
scaffoldCmd .Flags ().StringVar (& opts .OutputDir , "output-dir" , "" ,
61
- "Specifies the full path where the scaffolded files will be output. " +
62
- "Defaults to a directory within the current working directory." )
73
+ "Directory where the new project scaffold will be written. " +
74
+ "If unset, re-scaffolding occurs in-place " +
75
+ "and will delete existing files (except .git and PROJECT)." )
63
76
64
77
return scaffoldCmd
65
78
}
0 commit comments