show projects list to confirm

This commit is contained in:
Zoker 2020-06-06 17:26:09 +08:00
parent d7844f29e7
commit c81415baa0
2 changed files with 14 additions and 3 deletions

View File

@ -70,7 +70,7 @@ func syncGitee(c *gcli.Command, args []string) error {
fmt.Printf("Selected %s(https://gitee.com/%s) as namespace, Type: %s \n" +
"The following projects will be generated on Gitee: \n", selectedNp[0], selectedNp[1], selectedNp[2])
// projects list
share.ShowProjectLists("gitee.com", repos, selectedNp[1])
npEnsure, _ := interact.ReadLine("Next step: create projects and sync code, continue?(y/n)")
if npEnsure != "y" {
share.ExitMessage()

View File

@ -67,8 +67,10 @@ func isGitRepo(repoPath string) (isGit bool) {
func printRepos(repos []string) {
color.Yellow.Println(len(repos), "repositories detected, please check below: ")
alertFlag := false
for _, repo := range repos { // todo goroutine
fmt.Printf(repo)
for i, repo := range repos { // todo goroutine
i = i + 1
p := fmt.Sprintf("%d. %s", i, repo)
fmt.Printf(p)
size, outAlert, _ := repoSize(repo)
alertFlag = alertFlag || outAlert
if outAlert {
@ -160,3 +162,12 @@ func Post(uri string, params map[string]interface{}) (map[string]interface{}, er
json.Unmarshal(body, &result)
return result, nil
}
func ShowProjectLists(host string, repos []string, path string) {
for i, r := range repos {
i = i + 1
ra := strings.Split(r, "/")
p := fmt.Sprintf("%d. https://%s/%s/%s", i, host, path, ra[len(ra) - 1])
color.Yellow.Println(p)
}
}