Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: interfaces definition for dtm create command #1450

Merged
merged 1 commit into from
Feb 1, 2023
Merged
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
31 changes: 22 additions & 9 deletions internal/pkg/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import (
"time"
)

type Param struct {
GithubUsername string
GithubToken string
DockerhubUsername string
DockerhubToken string
Language string
Framework string
}

func Create() error {
helloMsg := func() {
fmt.Println("I'll scaffold a new repository for you.")
Expand All @@ -16,26 +25,30 @@ func Create() error {
}
helloMsg()

lang, err := getLanguage()
params, err := getParams()
if err != nil {
return err
}

time.Sleep(time.Second)
fmt.Println("\nPlease choose a framework next.")
time.Sleep(time.Second)
return create(params)
}

fram, err := getFramework()
// TODO: @jf
func create(params *Param) error {
err := createRepo(params)
if err != nil {
return err
}

return createRepo(lang, fram)
// TODO(daniel-hutao): cicd
return createApp(params)
}

// TODO(daniel-hutao): support python/flask first
func createRepo(lang, fram string) error {
fmt.Printf("Lang: %s, Fram: %s\n", lang, fram)
func createRepo(params *Param) error {
fmt.Printf("Lang: %s, Fram: %s\n", params.Language, params.Framework)
return nil
}

func createApp(params *Param) error {
return nil
}
27 changes: 27 additions & 0 deletions internal/pkg/create/param.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package create

import (
"fmt"
"time"
)

// TODO: @bird
func getParams() (*Param, error) {
lang, err := getLanguage()
if err != nil {
return nil, err
}

time.Sleep(time.Second)
fmt.Println("\nPlease choose a framework next.")
time.Sleep(time.Second)

fram, err := getFramework()
if err != nil {
return nil, err
}
return &Param{
Language: lang,
Framework: fram,
}, nil
}