add layout env (#897)

pull/898/head
Tony Chen 4 years ago committed by GitHub
parent 2e4bb11f00
commit eed0ac7d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      cmd/kratos/internal/project/project.go

@ -17,10 +17,13 @@ var CmdNew = &cobra.Command{
Run: run, Run: run,
} }
var repoUrl string var repoURL string
func init() { func init() {
CmdNew.Flags().StringVarP(&repoUrl, "-repo-url", "r", "https://github.com/go-kratos/kratos-layout.git", "layout repo") if repoURL = os.Getenv("KRATOS_LAYOUT_REPO"); repoURL == "" {
repoURL = "https://github.com/go-kratos/kratos-layout.git"
}
CmdNew.Flags().StringVarP(&repoURL, "-repo-url", "r", repoURL, "layout repo")
} }
func run(cmd *cobra.Command, args []string) { func run(cmd *cobra.Command, args []string) {
@ -35,7 +38,7 @@ func run(cmd *cobra.Command, args []string) {
return return
} }
p := &Project{Name: args[0]} p := &Project{Name: args[0]}
if err := p.New(ctx, wd, repoUrl); err != nil { if err := p.New(ctx, wd, repoURL); err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
return return
} }

Loading…
Cancel
Save