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

Commit 7753a8a

Browse files
committed
[main] reform & add introduction & fix
1 parent 5dec18e commit 7753a8a

File tree

1 file changed

+47
-21
lines changed

1 file changed

+47
-21
lines changed

src/fgit.go

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,17 @@ func main() {
131131
" Build by KevinZonda with GoLang\n" +
132132
"EXTRA-SYNTAX\n" +
133133
" fgit debug [URL<string>] [--help|-h]\n" +
134-
" fgit get [URL<string>] [Path<string>] [--help]" +
134+
" fgit get [URL<string>] [Path<string>] [--help|-h]\n" +
135+
" fgit conv [Target<string>] [--help|-h]\n " +
135136
" If you wan to known more about extra-syntax, try to use --help")
136137
os.Exit(0)
137138
}
138139

139140
isConvertToFastGit := false
140141
isPushOrPull := false
141142

142-
if os.Args[1] == "debug" {
143+
switch os.Args[1] {
144+
case "debug":
143145
var isConnectOk bool
144146
switch len(os.Args) {
145147
case 2:
@@ -151,16 +153,16 @@ func main() {
151153
}
152154
isConnectOk = debug(_i)
153155
default:
154-
fmt.Println("Invalid args for debug. If help wanted, use --help arg.")
156+
fmt.Println("Invalid args for debug. Use --help to get more information.")
155157
}
156158
if isConnectOk {
157159
os.Exit(0)
158160
} else {
159161
os.Exit(1)
160162
}
161-
}
162-
163-
if os.Args[1] == "get" || os.Args[1] == "dl" || os.Args[1] == "download" {
163+
case "get":
164+
case "dl":
165+
case "download":
164166
switch len(os.Args) {
165167
default:
166168
get("", "")
@@ -170,13 +172,12 @@ func main() {
170172
get(os.Args[2], os.Args[3])
171173
}
172174
os.Exit(0)
173-
}
174-
175-
if os.Args[1] == "conv" || os.Args[1] == "convert" {
175+
case "conv":
176+
case "convert":
176177
switch len(os.Args) {
177178
default:
178-
// TODO: ABOUT.CONVERT
179-
case 2:
179+
fmt.Println("Invalid args for conv. Use --help to get more information.")
180+
case 3:
180181
switch os.Args[2] {
181182
case "gh":
182183
case "github":
@@ -186,16 +187,41 @@ func main() {
186187
convertToFastGit()
187188
case "-h":
188189
case "--help":
189-
// TODO: HELP
190-
fmt.Println("Help")
190+
fmt.Println("" +
191+
"FastGit Conv Command Line Tool\n" +
192+
"==============================\n" +
193+
"REMARKS\n" +
194+
" Convert upstream between github or fastgit automatically\n" +
195+
" github and gh means convert to github, fastgit and fg means convert to fastgit" +
196+
"SYNTAX\n" +
197+
" fgit conv [--help|-h]\n" +
198+
" fgit conv [github|gh|fastgit|fg]\n" +
199+
"ALIASES\n" +
200+
" fgit convert\n" +
201+
"EXAMPLE\n" +
202+
" fgit conv gh")
191203
default:
192-
fmt.Println("Unknown args")
204+
fmt.Println("Invalid args for conv. Use --help to get more information.")
193205
}
206+
case 2:
207+
fmt.Println("" +
208+
"FastGit Conv Command Line Tool\n" +
209+
"==============================\n" +
210+
"REMARKS\n" +
211+
" Convert upstream between github or fastgit automatically\n" +
212+
" github and gh means convert to github, fastgit and fg means convert to fastgit" +
213+
"SYNTAX\n" +
214+
" fgit conv [--help|-h]\n" +
215+
" fgit conv [github|gh|fastgit|fg]\n" +
216+
"ALIASES\n" +
217+
" fgit convert\n" +
218+
"EXAMPLE\n" +
219+
" fgit conv gh")
194220
}
195221
os.Exit(0)
196-
}
197-
198-
if os.Args[1] == "-v" || os.Args[1] == "--version" || os.Args[1] == "version" {
222+
case "-v":
223+
case "--version":
224+
case "version":
199225
showVersion()
200226
}
201227

@@ -307,12 +333,12 @@ startDown:
307333
}
308334
}
309335
}
310-
newUrl := strings.Replace(url, "https://github.com", "https://download.fastgit.org", -1)
311-
if newUrl != url {
312-
fmt.Println("Redirect ->", newUrl)
336+
newURL := strings.Replace(url, "https://github.com", "https://download.fastgit.org", -1)
337+
if newURL != url {
338+
fmt.Println("Redirect ->", newURL)
313339
}
314340
fmt.Println("Downloading...")
315-
resp, err := http.Get(newUrl)
341+
resp, err := http.Get(newURL)
316342
checkErr(err, "Http.Get create failed", 1)
317343
defer resp.Body.Close()
318344

0 commit comments

Comments
 (0)