MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / PromptMissing

Function PromptMissing

pkg/cmd/project/branch/create/create.go:114–152  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

112}
113
114func PromptMissing(opts *CreateOptions) error {
115 var project *projects.Project
116 var err error
117 if opts.Project.Value == "" {
118 project, err = projectSelector("You have not specified a Project. Please select one:", opts.GetAllProjectsCallback, opts.Ask)
119 if err != nil {
120 return nil
121 }
122 opts.Project.Value = project.GetName()
123 } else {
124 project, err = opts.GetProjectCallback(opts.Project.Value)
125 if err != nil {
126 return err
127 }
128 }
129
130 if opts.Name.Value == "" {
131 if err := opts.Ask(&survey.Input{
132 Message: "Name",
133 Help: fmt.Sprintf("A name for the new branch."),
134 }, &opts.Name.Value, survey.WithValidator(survey.ComposeValidators(
135 survey.MaxLength(200),
136 survey.MinLength(1),
137 survey.Required,
138 ))); err != nil {
139 return err
140 }
141 }
142
143 if opts.BaseBranch.Value == "" {
144 branch, err := branchSelector("You have not specified a base branch. Please select one:", project.GetID(), opts)
145 if err != nil {
146 return err
147 }
148 opts.BaseBranch.Value = branch.CanonicalName
149 }
150
151 return nil
152}
153
154func projectSelector(questionText string, getAllProjectsCallback shared.GetAllProjectsCallback, ask question.Asker) (*projects.Project, error) {
155 existingProjects, err := getAllProjectsCallback()

Callers 3

CreateRunFunction · 0.70

Calls 4

branchSelectorFunction · 0.85
projectSelectorFunction · 0.70
GetNameMethod · 0.65
AskMethod · 0.65