(f factory.Factory)
| 57 | } |
| 58 | |
| 59 | func NewCmdCreate(f factory.Factory) *cobra.Command { |
| 60 | createFlags := NewCreateFlags() |
| 61 | cmd := &cobra.Command{ |
| 62 | Use: "create", |
| 63 | Short: "Create a channel", |
| 64 | Long: "Create a channel in Octopus Deploy", |
| 65 | Example: heredoc.Docf(` |
| 66 | %[1]s channel create |
| 67 | %[1]s channel create --name "The Channel" --project "The Project" --lifecycle "Default Lifecycle" --default |
| 68 | `, constants.ExecutableName), |
| 69 | RunE: func(c *cobra.Command, args []string) error { |
| 70 | opts := NewCreateOptions(createFlags, cmd.NewDependencies(f, c)) |
| 71 | |
| 72 | return createRun(opts) |
| 73 | }, |
| 74 | } |
| 75 | |
| 76 | flags := cmd.Flags() |
| 77 | flags.StringVarP(&createFlags.Name.Value, createFlags.Name.Name, "n", "", "Name of the channel") |
| 78 | flags.StringVarP(&createFlags.Project.Value, createFlags.Project.Name, "p", "", "Project to create channel in") |
| 79 | flags.StringVarP(&createFlags.Description.Value, createFlags.Description.Name, "d", "", "Description of the channel") |
| 80 | flags.StringVarP(&createFlags.Lifecycle.Value, createFlags.Lifecycle.Name, "l", "", "The lifecycle to use for the channel") |
| 81 | flags.BoolVar(&createFlags.Default.Value, createFlags.Default.Name, false, "Set this channel as default") |
| 82 | |
| 83 | return cmd |
| 84 | } |
| 85 | |
| 86 | func createRun(opts *CreateOptions) error { |
| 87 | if !opts.NoPrompt { |
nothing calls this directly
no test coverage detected