From b35e7be38769441f04b86e87143b24373d788691 Mon Sep 17 00:00:00 2001 From: toshinari123 Date: Tue, 5 Mar 2024 13:30:23 +0800 Subject: [PATCH] create cobra command 2 --- cmd/pageship/app/generate.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/pageship/app/generate.go b/cmd/pageship/app/generate.go index 81eec66..3067433 100644 --- a/cmd/pageship/app/generate.go +++ b/cmd/pageship/app/generate.go @@ -14,8 +14,9 @@ func init() { var generateCmd = &cobra.Command{ Use: "generate [command]", Short: "Generate files", + Args: cobra.NoArgs, //if unknown command, will return error just like main pageship command RunE: func(cmd *cobra.Command, args []string) error { - fmt.Println("guh") + cmd.Help() //show help if no subcommand supplied return nil }, } @@ -24,7 +25,7 @@ var generateDockerfileCmd = &cobra.Command{ Use: "dockerfile", Short: "Generate dockerfile", RunE: func(cmd *cobra.Command, args []string) error { - fmt.Println("guh") + fmt.Println("buh") return nil }, }