prevent overwrite of RunE

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
Christian Richter
2025-12-15 16:40:27 +01:00
committed by Florian Schade
parent a9b1bea4f8
commit 0fa3a2a7f8
+8 -3
View File
@@ -24,9 +24,14 @@ func Execute() error {
for _, fn := range register.Commands { for _, fn := range register.Commands {
cmd := fn(cfg) cmd := fn(cfg)
cmd.RunE = func(cmd *cobra.Command, args []string) error { // if the command has a RunE function, it is a subcommand of root
cmd.Help() // if not it is a consumed root command from the services
return nil // wee need to overwrite the RunE function to get the help output there
if cmd.RunE == nil {
cmd.RunE = func(cmd *cobra.Command, args []string) error {
cmd.Help()
return nil
}
} }
app.AddCommand(cmd) app.AddCommand(cmd)
} }