github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/prompts/smartops/new.go (about) 1 package smartopsPrompts 2 3 import ( 4 structureSpec "github.com/taubyte/go-specs/structure" 5 smartopsLib "github.com/taubyte/tau-cli/lib/smartops" 6 "github.com/taubyte/tau-cli/prompts" 7 "github.com/urfave/cli/v2" 8 ) 9 10 func New(ctx *cli.Context) (smartops *structureSpec.SmartOp, templateURL string, err error) { 11 smartops = &structureSpec.SmartOp{} 12 13 taken, err := smartopsLib.List() 14 if err != nil { 15 return 16 } 17 18 smartops.Name = prompts.GetOrRequireAUniqueName(ctx, NamePrompt, taken) 19 20 templateURL, err = checkTemplate(ctx, smartops) 21 if err != nil { 22 return 23 } 24 25 smartops.Description = prompts.GetOrAskForADescription(ctx, smartops.Description) 26 smartops.Tags = prompts.GetOrAskForTags(ctx, smartops.Tags) 27 28 smartops.Timeout, err = prompts.GetOrRequireATimeout(ctx, smartops.Timeout) 29 if err != nil { 30 return 31 } 32 33 smartops.Memory, err = prompts.GetOrRequireMemoryAndType(ctx, smartops.Memory == 0, smartops.Memory) 34 if err != nil { 35 return 36 } 37 38 source, err := prompts.GetOrSelectSource(ctx, smartops.Source) 39 if err != nil { 40 return 41 } 42 smartops.Source = source.String() 43 44 smartops.Call = prompts.GetOrRequireACall(ctx, source, smartops.Call) 45 46 return 47 }