From a9b1bea4f862b1e7fd46f139112771f984c0d0d4 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 8 Dec 2025 09:40:33 +0100 Subject: [PATCH] override RunE function of root subcommands to ensure that help is shown when no arguments are given Signed-off-by: Christian Richter --- opencloud/pkg/command/root.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/opencloud/pkg/command/root.go b/opencloud/pkg/command/root.go index ac1dc4bace..91d7d1edf8 100644 --- a/opencloud/pkg/command/root.go +++ b/opencloud/pkg/command/root.go @@ -23,7 +23,12 @@ func Execute() error { }) for _, fn := range register.Commands { - app.AddCommand(fn(cfg)) + cmd := fn(cfg) + cmd.RunE = func(cmd *cobra.Command, args []string) error { + cmd.Help() + return nil + } + app.AddCommand(cmd) } app.SetArgs(os.Args[1:]) ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)