Skip to content

Commit 0c3b376

Browse files
authored
Merge pull request #4846 from camilamacedo86/fix-help-info-alpha
✨ (cli): enhance help information for kubebuilder alpha generate command
2 parents 8469e62 + 0b5f164 commit 0c3b376

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

pkg/cli/alpha/command.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,43 @@ import (
3636
// code of external projects is not feasible within Kubebuilder’s current design.
3737
func NewScaffoldCommand() *cobra.Command {
3838
opts := internal.Generate{}
39+
3940
scaffoldCmd := &cobra.Command{
4041
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+
`,
4858
PreRunE: func(_ *cobra.Command, _ []string) error {
4959
return opts.Validate()
5060
},
5161
Run: func(_ *cobra.Command, _ []string) {
5262
if err := opts.Generate(); err != nil {
53-
log.Fatalf("Failed to command %s", err)
63+
log.Fatalf("failed to generate project: %s", err)
5464
}
5565
},
5666
}
67+
5768
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+
6072
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).")
6376

6477
return scaffoldCmd
6578
}

0 commit comments

Comments
 (0)