Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit 182f032

Browse files
committed
[get] make more user-friend
1 parent 4f1e6fa commit 182f032

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

fgit.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ func debug(url string) bool {
4848
resp, err := http.Get("https://api.ip.sb/ip")
4949
defer resp.Body.Close()
5050
if err != nil {
51-
fmt.Println("Unknown -> ", err)
51+
fmt.Println("Unknown ->", err)
5252
} else {
5353
s, err := ioutil.ReadAll(resp.Body)
5454
if err != nil {
55-
fmt.Println("Unknown -> ", err)
55+
fmt.Println("Unknown ->", err)
5656
} else {
5757
fmt.Printf("[%s]\n", strings.Replace(string(s), "\n", "", -1))
5858
}
@@ -105,8 +105,8 @@ func convertHelper(oldPrefixValue, newPrefixValue string) bool {
105105

106106
func checkErr(err error, msg string, exitCode int) {
107107
if err != nil {
108-
fmt.Println("Exception Detective: ", msg)
109-
fmt.Println("Tracker: ", err)
108+
fmt.Println("Exception:", msg)
109+
fmt.Println("Tracker:", err)
110110
os.Exit(exitCode)
111111
}
112112
}
@@ -222,14 +222,15 @@ func downloadFile(url, fpath string) {
222222
downloadFile(url, fpath)
223223
} else {
224224
isContinue := ' '
225-
fmt.Scanf("%c", isContinue)
225+
fmt.Print("File with the same name exists. New file will cover the old file.\nDo you want to continue? [Y/n]")
226+
fmt.Scanf("%c", &isContinue)
226227

227228
switch strings.ToLower(string(isContinue)) {
228229
case "y":
229230
os.Remove(fpath)
230231
goto startDown
231232
case "n":
232-
fmt.Println("User cancle the command")
233+
fmt.Println("User cancle the operation.")
233234
os.Exit(0)
234235
default:
235236
fmt.Println("Unknown input, exiting...")
@@ -243,6 +244,7 @@ func downloadFile(url, fpath string) {
243244
if newUrl != url {
244245
fmt.Println("Redirect url ->", newUrl)
245246
}
247+
fmt.Println("Downloading...")
246248
resp, err := http.Get(newUrl)
247249
checkErr(err, "Http.Get create failed", 1)
248250
defer resp.Body.Close()
@@ -252,6 +254,7 @@ func downloadFile(url, fpath string) {
252254
defer out.Close()
253255
_, err = io.Copy(out, resp.Body)
254256
checkErr(err, "io.Copy failed!", 1)
257+
fmt.Println("Finished.")
255258
os.Exit(0)
256259
}
257260

0 commit comments

Comments
 (0)