(f factory.Factory)
| 58 | } |
| 59 | |
| 60 | func NewCmdCreate(f factory.Factory) *cobra.Command { |
| 61 | createFlags := NewCreateFlags() |
| 62 | cmd := &cobra.Command{ |
| 63 | Use: "create", |
| 64 | Short: "Create a Git branch for a project", |
| 65 | Long: "Create a Git branch for a project in Octopus Deploy", |
| 66 | Aliases: []string{"add"}, |
| 67 | Example: heredoc.Docf(` |
| 68 | %[1]s project branch create |
| 69 | %[1]s project branch create --project "Deploy Website" --name branch-name --base-branch refs/heads/main |
| 70 | `, constants.ExecutableName), |
| 71 | RunE: func(c *cobra.Command, args []string) error { |
| 72 | opts := NewCreateOptions(createFlags, cmd.NewDependencies(f, c)) |
| 73 | |
| 74 | return CreateRun(opts) |
| 75 | }, |
| 76 | } |
| 77 | |
| 78 | flags := cmd.Flags() |
| 79 | flags.StringVarP(&createFlags.Project.Value, createFlags.Project.Name, "p", "", "The project") |
| 80 | flags.StringVarP(&createFlags.Name.Value, createFlags.Name.Name, "n", "", "The name of the branch") |
| 81 | flags.StringVarP(&createFlags.BaseBranch.Value, createFlags.BaseBranch.Name, "", "", "The git-ref branch to create a new branch from") |
| 82 | |
| 83 | return cmd |
| 84 | } |
| 85 | |
| 86 | func CreateRun(opts *CreateOptions) error { |
| 87 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected