|
|
@ -6,10 +6,10 @@ import ( |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/AlecAivazis/survey/v2" |
|
|
|
"github.com/AlecAivazis/survey/v2" |
|
|
|
"github.com/fatih/color" |
|
|
|
"github.com/fatih/color" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Project is a project template.
|
|
|
|
// Project is a project template.
|
|
|
@ -23,11 +23,11 @@ func (p *Project) New(ctx context.Context, dir string, layout string, branch str |
|
|
|
to := path.Join(dir, p.Name) |
|
|
|
to := path.Join(dir, p.Name) |
|
|
|
if _, err := os.Stat(to); !os.IsNotExist(err) { |
|
|
|
if _, err := os.Stat(to); !os.IsNotExist(err) { |
|
|
|
fmt.Printf("🚫 %s already exists\n", p.Name) |
|
|
|
fmt.Printf("🚫 %s already exists\n", p.Name) |
|
|
|
override := false |
|
|
|
|
|
|
|
prompt := &survey.Confirm{ |
|
|
|
prompt := &survey.Confirm{ |
|
|
|
Message: "📂 Do you want to override the folder ?", |
|
|
|
Message: "📂 Do you want to override the folder ?", |
|
|
|
Help: "Delete the existing folder and create the project.", |
|
|
|
Help: "Delete the existing folder and create the project.", |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var override bool |
|
|
|
e := survey.AskOne(prompt, &override) |
|
|
|
e := survey.AskOne(prompt, &override) |
|
|
|
if e != nil { |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
return e |
|
|
|