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

GH-194 isx clone 默认下载到当前路径 #202

Merged
merged 1 commit into from
Jul 6, 2024
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
17 changes: 14 additions & 3 deletions cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,21 @@ func inputProjectNumber() {
}

func inputProjectPath() {

currentWorkDir := common.CurrentWorkDir()
// 输入安装路径
fmt.Print("请输入安装路径:")
fmt.Scanln(&projectPath)
fmt.Printf("是否安装在当前路径(%s)下? (y/n) ", common.WhiteText(currentWorkDir))
var flag = ""
fmt.Scanln(&flag)
flag = strings.Trim(flag, " ")
for flag == "y" || flag == "n" {
if flag == "y" {
projectPath = currentWorkDir
}
if flag == "n" {
fmt.Print("请输入安装路径:")
fmt.Scanln(&projectPath)
}
}

// 支持克隆路径替换~为当前用户目录
if strings.HasPrefix(projectPath, "~/") {
Expand Down
47 changes: 47 additions & 0 deletions common/color.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright © 2024 jamie HERE <EMAIL ADDRESS>
*/
package common

const (
Reset = "\033[0m"
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Purple = "\033[35m"
Cyan = "\033[36m"
White = "\033[37m"
)

func textWithColor(color, text string) string {
return color + text + Reset
}

func RedText(text string) string {
return textWithColor(Red, text)
}

func GreenText(text string) string {
return textWithColor(Green, text)
}

func YellowText(text string) string {
return textWithColor(Yellow, text)
}

func BlueText(text string) string {
return textWithColor(Blue, text)
}

func PurpleText(text string) string {
return textWithColor(Purple, text)
}

func CyanText(text string) string {
return textWithColor(Cyan, text)
}

func WhiteText(text string) string {
return textWithColor(White, text)
}
9 changes: 9 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ func HomeDir() string {
}
return home
}

func CurrentWorkDir() string {
dir, err := os.Getwd()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return dir
}