@@ -162,9 +162,14 @@ func initConfig() {
162
162
}
163
163
164
164
func executeVersionCommand (cmd * cobra.Command , args []string ) {
165
- versionsToPrint := make ([]string , 0 , 10 )
166
- descendants := make ([]* cobra.Command , 0 , 10 )
167
- versionsToPrint = append (versionsToPrint , cmd .Parent ().Name ())
165
+ versionPrint (versionsToPrint (cmd , true )... )
166
+ }
167
+
168
+ func versionsToPrint (cmd * cobra.Command , isRoot bool ) []string {
169
+ verToPrint := make ([]string , 0 , 10 )
170
+ if isRoot {
171
+ verToPrint = append (verToPrint , cmd .Parent ().Name ())
172
+ }
168
173
169
174
if GlobalFlags .Verbose > 0 {
170
175
siblings := findSiblings (cmd )
@@ -173,17 +178,15 @@ func executeVersionCommand(cmd *cobra.Command, args []string) {
173
178
for _ , sibChild := range sibling .Commands () {
174
179
//fmt.Println(sibling.Name(), " >", sibChild.Name())
175
180
if sibChild .Name () == "version" {
176
- versionsToPrint = append (versionsToPrint , sibling .Name ())
181
+ verToPrint = append (verToPrint , sibling .Name ())
182
+ } else {
183
+ verToPrint = append (verToPrint , versionsToPrint (sibChild , false )... )
177
184
}
178
185
}
179
186
}
180
187
}
181
188
182
- versionPrint (versionsToPrint ... )
183
-
184
- for _ , descendant := range descendants {
185
- executeVersionCommand (descendant , args )
186
- }
189
+ return verToPrint
187
190
}
188
191
189
192
// versionPrint formats and prints the version of the specified command.
0 commit comments