github.com/jenkins-x/jx/v2@v2.1.155/pkg/cmd/get/get_lang.go (about) 1 package get 2 3 import ( 4 "os" 5 6 "github.com/jenkins-x/jx/v2/pkg/cmd/helper" 7 "github.com/jenkins-x/jx/v2/pkg/cmd/opts" 8 "github.com/jenkins-x/jx/v2/pkg/cmd/opts/step" 9 "github.com/jenkins-x/jx/v2/pkg/cmd/templates" 10 "github.com/jenkins-x/jx/v2/pkg/config" 11 "github.com/spf13/cobra" 12 ) 13 14 // GetLangOptions containers the CLI options 15 type GetLangOptions struct { 16 Options 17 StepOptions step.StepOptions 18 19 Pending bool 20 } 21 22 var ( 23 getPackLong = templates.LongDesc(` 24 Display the pack of the current directory 25 `) 26 27 getPackExample = templates.Examples(` 28 # Print the lang 29 jx get lang 30 `) 31 ) 32 33 // NewCmdGetLang creates the new command for: jx get env 34 func NewCmdGetLang(commonOpts *opts.CommonOptions) *cobra.Command { 35 options := &GetLangOptions{ 36 Options: Options{ 37 CommonOptions: commonOpts, 38 }, 39 StepOptions: step.StepOptions{ 40 CommonOptions: commonOpts, 41 }, 42 } 43 cmd := &cobra.Command{ 44 Use: "lang", 45 Short: "Display the pack of the current working directory", 46 Aliases: []string{"lang"}, 47 Long: getPackLong, 48 Example: getPackExample, 49 Run: func(cmd *cobra.Command, args []string) { 50 options.Cmd = cmd 51 options.Args = args 52 err := options.Run() 53 helper.CheckErr(err) 54 }, 55 } 56 57 options.AddGetFlags(cmd) 58 return cmd 59 } 60 61 // Run implements this command 62 func (o *GetLangOptions) Run() error { 63 dir, err := os.Getwd() 64 if err != nil { 65 return err 66 } 67 projectConfig, _, err := config.LoadProjectConfig(dir) 68 69 //args := &opts.InvokeDraftPack{ 70 // Dir: dir, 71 // CustomDraftPack: "", 72 // DisableAddFiles: true, 73 // UseNextGenPipeline: false, 74 //} 75 _, err = o.StepOptions.DiscoverBuildPack(dir, projectConfig, "") 76 //_, err = o.InvokeDraftPack(args) 77 return err 78 }