| 221 | } |
| 222 | |
| 223 | func PromptMissing(opts *CreateOptions) error { |
| 224 | var project *projects.Project |
| 225 | var err error |
| 226 | if opts.Project.Value == "" { |
| 227 | project, err = projectSelector("You have not specified a Project. Please select one:", opts.GetAllProjectsCallback, opts.Ask) |
| 228 | if err != nil { |
| 229 | return nil |
| 230 | } |
| 231 | opts.Project.Value = project.GetName() |
| 232 | } else { |
| 233 | project, err = opts.GetProjectCallback(opts.Project.Value) |
| 234 | if err != nil { |
| 235 | return err |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | err = PromptVersionControl(opts, project) |
| 240 | if err != nil { |
| 241 | return err |
| 242 | } |
| 243 | |
| 244 | if opts.Name.Value == "" { |
| 245 | if err := opts.Ask(&survey.Input{ |
| 246 | Message: "Name", |
| 247 | Help: fmt.Sprintf("A name for this variable."), |
| 248 | }, &opts.Name.Value, survey.WithValidator(survey.ComposeValidators( |
| 249 | survey.MaxLength(200), |
| 250 | survey.MinLength(1), |
| 251 | survey.Required, |
| 252 | ))); err != nil { |
| 253 | return err |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | question.AskDescription(opts.Ask, "", "Variable", &opts.Description.Value) |
| 258 | |
| 259 | if opts.Type.Value == "" { |
| 260 | selectedType, err := selectors.SelectOptions(opts.Ask, "Select the type of the variable", getVariableTypeOptions) |
| 261 | if err != nil { |
| 262 | return err |
| 263 | } |
| 264 | opts.Type.Value = selectedType.Value |
| 265 | } |
| 266 | |
| 267 | if !opts.IsPrompted.Value { |
| 268 | opts.Ask(&survey.Confirm{ |
| 269 | Message: "Is this a prompted variable?", |
| 270 | Default: false, |
| 271 | }, &opts.IsPrompted.Value) |
| 272 | } |
| 273 | |
| 274 | if opts.IsPrompted.Value { |
| 275 | if opts.PromptLabel.Value == "" { |
| 276 | if err := opts.Ask(&survey.Input{ |
| 277 | Message: "Prompt Label", |
| 278 | }, &opts.PromptLabel.Value); err != nil { |
| 279 | return err |
| 280 | } |