这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cli/commands/actions_use_codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,6 @@ func (o *actionsUseCodegenOptions) run() error {
o.withStarterKit = shouldCloneStarterKit == "y"
}

// if output directory is not provided, make them enter it
if o.outputDir == "" {
outputDir, err := util.GetFSPathPrompt("Where do you want to place the codegen files?", o.EC.Config.ActionConfig.Codegen.OutputDir)
if err != nil {
return errors.Wrap(err, "error in getting output directory input")
}
newCodegenExecutionConfig.OutputDir = outputDir
} else {
newCodegenExecutionConfig.OutputDir = o.outputDir
}

// clone the starter kit
o.EC.Spin("Clonning the starter kit...")
if o.withStarterKit && hasStarterKit {
Expand Down Expand Up @@ -159,6 +148,17 @@ func (o *actionsUseCodegenOptions) run() error {
o.EC.Logger.Info("Starter kit cloned at " + destinationDir)
}

// if output directory is not provided, make them enter it
if o.outputDir == "" {
outputDir, err := util.GetFSPathPrompt("Where do you want to place the codegen files?", o.EC.Config.ActionConfig.Codegen.OutputDir)
if err != nil {
return errors.Wrap(err, "error in getting output directory input")
}
newCodegenExecutionConfig.OutputDir = outputDir
} else {
newCodegenExecutionConfig.OutputDir = o.outputDir
}

newConfig := o.EC.Config
newConfig.ActionConfig.Codegen = newCodegenExecutionConfig
err = o.EC.WriteConfig(newConfig)
Expand Down
13 changes: 1 addition & 12 deletions cli/util/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const (
)

func GetYesNoPrompt(message string) (promptResp string, err error) {

prompt := promptui.Prompt{
Label: message + " (y/n)",
Validate: func(_resp string) (err error) {
Expand All @@ -28,38 +27,28 @@ func GetYesNoPrompt(message string) (promptResp string, err error) {
},
Default: "y",
}

promptResp, err = prompt.Run()
if err != nil {
return
}
promptResp = string(strings.ToLower(promptResp)[0])

return

}

func GetSelectPrompt(message string, options []string) (selection string, err error) {
prompt := promptui.Select{
Label: message,
Items: options,
}

_, selection, err = prompt.Run()

return
}

func GetFSPathPrompt(message string, def string) (input string, err error) {

prompt := promptui.Prompt{
Label: message,
Validate: FSCheckIfDirPathExists,
Default: def,
}

input, err = prompt.Run()

return

return prompt.Run()
}