File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ type CLI struct { //nolint:maligned
48
48
commandName string
49
49
// CLI version string.
50
50
version string
51
+ // CLI root's command description.
52
+ description string
51
53
// Plugins registered in the CLI.
52
54
plugins map [string ]plugin.Plugin
53
55
// Default plugins in case none is provided and a config file can't be found.
@@ -120,7 +122,9 @@ func New(options ...Option) (*CLI, error) {
120
122
func newCLI (options ... Option ) (* CLI , error ) {
121
123
// Default CLI options.
122
124
c := & CLI {
123
- commandName : "kubebuilder" ,
125
+ commandName : "kubebuilder" ,
126
+ description : `CLI tool for building Kubernetes extensions and tools.
127
+ ` ,
124
128
plugins : make (map [string ]plugin.Plugin ),
125
129
defaultPlugins : make (map [config.Version ][]string ),
126
130
fs : machinery.Filesystem {FS : afero .NewOsFs ()},
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ func WithVersion(version string) Option {
44
44
}
45
45
}
46
46
47
+ // WithDescription is an Option that sets the CLI's root description.
48
+ func WithDescription (description string ) Option {
49
+ return func (c * CLI ) error {
50
+ c .description = description
51
+ return nil
52
+ }
53
+ }
54
+
47
55
// WithPlugins is an Option that sets the CLI's plugins.
48
56
//
49
57
// Specifying any invalid plugin results in an error.
Original file line number Diff line number Diff line change @@ -67,6 +67,16 @@ var _ = Describe("CLI options", func() {
67
67
})
68
68
})
69
69
70
+ Context ("WithDescription" , func () {
71
+ It ("should use the provided description string" , func () {
72
+ description := "alternative description"
73
+ c , err = newCLI (WithDescription (description ))
74
+ Expect (err ).NotTo (HaveOccurred ())
75
+ Expect (c ).NotTo (BeNil ())
76
+ Expect (c .description ).To (Equal (description ))
77
+ })
78
+ })
79
+
70
80
Context ("WithPlugins" , func () {
71
81
It ("should return a valid CLI" , func () {
72
82
c , err = newCLI (WithPlugins (p ))
Original file line number Diff line number Diff line change @@ -31,9 +31,8 @@ const (
31
31
32
32
func (c CLI ) newRootCmd () * cobra.Command {
33
33
cmd := & cobra.Command {
34
- Use : c .commandName ,
35
- Long : `CLI tool for building Kubernetes extensions and tools.
36
- ` ,
34
+ Use : c .commandName ,
35
+ Long : c .description ,
37
36
Example : c .rootExamples (),
38
37
RunE : func (cmd * cobra.Command , args []string ) error {
39
38
return cmd .Help ()
You can’t perform that action at this time.
0 commit comments