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

Function PromptMissing

pkg/cmd/space/create/create.go:201–251  ·  view source on GitHub ↗
(opts *CreateOptions)

Source from the content-addressed store, hash-verified

199}
200
201func PromptMissing(opts *CreateOptions) error {
202 existingSpaces, err := opts.GetAllSpacesCallback()
203 if err != nil {
204 return err
205 }
206
207 spaceNames := util.SliceTransform(existingSpaces, func(s *spaces.Space) string { return s.Name })
208 if opts.Name.Value == "" {
209 err = opts.Ask(&survey.Input{
210 Help: "The name of the space being created.",
211 Message: "Name",
212 }, &opts.Name.Value, survey.WithValidator(survey.ComposeValidators(
213 survey.MaxLength(20),
214 survey.MinLength(1),
215 survey.Required,
216 validation.NotEquals(spaceNames, "a space with this name already exists"),
217 )))
218 if err != nil {
219 return err
220 }
221 }
222
223 err = question.AskDescription(opts.Ask, "", "space", &opts.Description.Value)
224 if err != nil {
225 return err
226 }
227
228 if len(opts.Teams.Value) == 0 {
229 selectedTeams, err := selectTeams(opts.Ask, opts.GetAllTeamsCallback, existingSpaces, "Select one or more teams to manage this space:")
230 if err != nil {
231 return err
232 }
233
234 for _, team := range selectedTeams {
235 opts.Teams.Value = append(opts.Teams.Value, team.Name)
236 }
237 }
238
239 if len(opts.Users.Value) == 0 {
240 selectedUsers, err := selectUsers(opts.Ask, opts.GetAllUsersCallback, "Select one or more users to manage this space:")
241 if err != nil {
242 return err
243 }
244
245 for _, user := range selectedUsers {
246 opts.Users.Value = append(opts.Users.Value, user.Username)
247 }
248 }
249
250 return nil
251}

Callers 3

createRunFunction · 0.70

Calls 6

SliceTransformFunction · 0.92
NotEqualsFunction · 0.92
AskDescriptionFunction · 0.92
selectTeamsFunction · 0.85
selectUsersFunction · 0.85
AskMethod · 0.65