From e64e10f79b40db17a1cb24d9dd7ce7154f159f16 Mon Sep 17 00:00:00 2001 From: toshinari123 Date: Tue, 5 Mar 2024 12:14:11 +0800 Subject: [PATCH] Create cobra command --- cmd/pageship/app/generate.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cmd/pageship/app/generate.go diff --git a/cmd/pageship/app/generate.go b/cmd/pageship/app/generate.go new file mode 100644 index 0000000..3067433 --- /dev/null +++ b/cmd/pageship/app/generate.go @@ -0,0 +1,31 @@ +package app + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +func init() { + rootCmd.AddCommand(generateCmd) + generateCmd.AddCommand(generateDockerfileCmd) +} + +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 { + cmd.Help() //show help if no subcommand supplied + return nil + }, +} + +var generateDockerfileCmd = &cobra.Command{ + Use: "dockerfile", + Short: "Generate dockerfile", + RunE: func(cmd *cobra.Command, args []string) error { + fmt.Println("buh") + return nil + }, +}