github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/get/get_branchpattern.go (about) 1 package get 2 3 import ( 4 "github.com/olli-ai/jx/v2/pkg/cmd/helper" 5 "github.com/olli-ai/jx/v2/pkg/cmd/opts" 6 "github.com/olli-ai/jx/v2/pkg/cmd/templates" 7 "github.com/spf13/cobra" 8 ) 9 10 // GetBranchPatternOptions containers the CLI options 11 type GetBranchPatternOptions struct { 12 Options 13 } 14 15 var ( 16 getBranchPatternLong = templates.LongDesc(` 17 Display the git branch patterns for the current Team used on creating and importing projects 18 19 For more documentation see: [https://jenkins-x.io/docs/using-jx/creating/import/#branch-patterns](https://jenkins-x.io/docs/using-jx/creating/import/#branch-patterns) 20 `) 21 22 getBranchPatternExample = templates.Examples(` 23 # List the git branch patterns for the current team 24 jx get branchpattern 25 `) 26 ) 27 28 // NewCmdGetBranchPattern creates the new command for: jx get env 29 func NewCmdGetBranchPattern(commonOpts *opts.CommonOptions) *cobra.Command { 30 options := &GetBranchPatternOptions{ 31 Options: Options{ 32 CommonOptions: commonOpts, 33 }, 34 } 35 cmd := &cobra.Command{ 36 Use: opts.BranchPatternCommandName, 37 Short: "Display the git branch patterns for the current Team used on creating and importing projects", 38 Aliases: opts.BranchPatternCommandAliases, 39 Long: getBranchPatternLong, 40 Example: getBranchPatternExample, 41 Run: func(cmd *cobra.Command, args []string) { 42 options.Cmd = cmd 43 options.Args = args 44 err := options.Run() 45 helper.CheckErr(err) 46 }, 47 } 48 49 options.AddGetFlags(cmd) 50 return cmd 51 } 52 53 // Run implements this command 54 func (o *GetBranchPatternOptions) Run() error { 55 patterns, err := o.TeamBranchPatterns() 56 if err != nil { 57 return err 58 } 59 table := o.CreateTable() 60 table.AddRow("BRANCH PATTERNS") 61 table.AddRow(patterns.DefaultBranchPattern) 62 table.Render() 63 return nil 64 }