File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -140,15 +140,16 @@ func Execute() {
140140 }
141141 }
142142
143- for _ , c := range RootCmd . Commands ( ) {
143+ applyToAllCommands ( RootCmd , func ( c * cobra. Command ) {
144144 c .Short = translate .T (c .Short )
145145 c .Long = translate .T (c .Long )
146146 c .Flags ().VisitAll (func (f * pflag.Flag ) {
147147 f .Usage = translate .T (f .Usage )
148148 })
149149
150150 c .SetUsageTemplate (usageTemplate ())
151- }
151+ })
152+
152153 RootCmd .Short = translate .T (RootCmd .Short )
153154 RootCmd .Long = translate .T (RootCmd .Long )
154155 RootCmd .Flags ().VisitAll (func (f * pflag.Flag ) {
@@ -341,3 +342,13 @@ func addToPath(dir string) {
341342func validateUsername (name string ) bool {
342343 return len (name ) <= 60
343344}
345+
346+ // applyToAllCommands applies the provided func to all commands including sub commands
347+ func applyToAllCommands (cmd * cobra.Command , f func (subCmd * cobra.Command )) {
348+ for _ , c := range cmd .Commands () {
349+ f (c )
350+ if c .HasSubCommands () {
351+ applyToAllCommands (c , f )
352+ }
353+ }
354+ }
You can’t perform that action at this time.
0 commit comments