github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/add/add.go (about) 1 package add 2 3 import ( 4 "github.com/olli-ai/jx/v2/pkg/cmd/helper" 5 "github.com/spf13/cobra" 6 7 "github.com/olli-ai/jx/v2/pkg/cmd/opts" 8 "github.com/olli-ai/jx/v2/pkg/cmd/templates" 9 ) 10 11 // AddOptions contains the command line options 12 type AddOptions struct { 13 *opts.CommonOptions 14 15 DisableImport bool 16 OutDir string 17 } 18 19 var ( 20 add_resources = `Valid resource types include: 21 22 * app 23 ` 24 25 add_long = templates.LongDesc(` 26 Adds a new resource. 27 28 ` + add_resources + ` 29 `) 30 ) 31 32 // NewCmdAdd creates a command object for the "add" command 33 func NewCmdAdd(commonOpts *opts.CommonOptions) *cobra.Command { 34 options := &AddOptions{ 35 CommonOptions: commonOpts, 36 } 37 38 cmd := &cobra.Command{ 39 Use: "add", 40 Short: "Adds a new resource", 41 Long: add_long, 42 Run: func(cmd *cobra.Command, args []string) { 43 options.Cmd = cmd 44 options.Args = args 45 err := options.Run() 46 helper.CheckErr(err) 47 }, 48 } 49 cmd.AddCommand(NewCmdAddApp(commonOpts)) 50 return cmd 51 } 52 53 // Run implements this command 54 func (o *AddOptions) Run() error { 55 return o.Cmd.Help() 56 }