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

Commit d68630e

Browse files
committed
[main] reform
1 parent 9cade38 commit d68630e

File tree

1 file changed

+31
-40
lines changed

1 file changed

+31
-40
lines changed

src/fgit.go

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func debug(url string) bool {
4545
"FastGit Debug Command Line Tool\n" +
4646
"===============================")
4747
if url != "--help" && url != "-h" {
48+
if !(strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://")) {
49+
url = "http://" + url
50+
}
4851
fmt.Println("Remote Address:", url)
4952
fmt.Print("IP Address: ")
5053
addr, err := net.LookupIP(strings.Replace(strings.Replace(url, "https://", "", -1), "http://", "", -1))
@@ -121,6 +124,31 @@ func checkErr(err error, msg string, exitCode int) {
121124
}
122125
}
123126

127+
func conv(target string) {
128+
switch target {
129+
case "gh", "github":
130+
convertToGitHub()
131+
case "fg", "fastgit":
132+
convertToFastGit()
133+
case "-h", "--help":
134+
fmt.Println("" +
135+
"FastGit Conv Command Line Tool\n" +
136+
"==============================\n" +
137+
"REMARKS\n" +
138+
" Convert upstream between github or fastgit automatically\n" +
139+
" github and gh means convert to github, fastgit and fg means convert to fastgit" +
140+
"SYNTAX\n" +
141+
" fgit conv [--help|-h]\n" +
142+
" fgit conv [github|gh|fastgit|fg]\n" +
143+
"ALIASES\n" +
144+
" fgit convert\n" +
145+
"EXAMPLE\n" +
146+
" fgit conv gh")
147+
default:
148+
fmt.Println("Invalid args for conv. Use --help to get more information.")
149+
}
150+
}
151+
124152
func main() {
125153
if len(os.Args) == 1 || (len(os.Args) == 2 && (os.Args[1] == "--help" || os.Args[1] == "-h")) {
126154
fmt.Println("" +
@@ -148,11 +176,7 @@ func main() {
148176
case 2:
149177
isConnectOk = debug("https://hub.fastgit.org")
150178
case 3:
151-
_i := os.Args[2]
152-
if !(strings.HasPrefix(_i, "http://") || strings.HasPrefix(_i, "https://")) {
153-
_i = "http://" + _i
154-
}
155-
isConnectOk = debug(_i)
179+
isConnectOk = debug(os.Args[2])
156180
default:
157181
fmt.Println("Invalid args for debug. Use --help to get more information.")
158182
}
@@ -176,42 +200,9 @@ func main() {
176200
default:
177201
fmt.Println("Invalid args for conv. Use --help to get more information.")
178202
case 3:
179-
switch os.Args[2] {
180-
case "gh", "github":
181-
convertToGitHub()
182-
case "fg", "fastgit":
183-
convertToFastGit()
184-
case "-h", "--help":
185-
fmt.Println("" +
186-
"FastGit Conv Command Line Tool\n" +
187-
"==============================\n" +
188-
"REMARKS\n" +
189-
" Convert upstream between github or fastgit automatically\n" +
190-
" github and gh means convert to github, fastgit and fg means convert to fastgit" +
191-
"SYNTAX\n" +
192-
" fgit conv [--help|-h]\n" +
193-
" fgit conv [github|gh|fastgit|fg]\n" +
194-
"ALIASES\n" +
195-
" fgit convert\n" +
196-
"EXAMPLE\n" +
197-
" fgit conv gh")
198-
default:
199-
fmt.Println("Invalid args for conv. Use --help to get more information.")
200-
}
203+
conv(os.Args[2])
201204
case 2:
202-
fmt.Println("" +
203-
"FastGit Conv Command Line Tool\n" +
204-
"==============================\n" +
205-
"REMARKS\n" +
206-
" Convert upstream between github or fastgit automatically\n" +
207-
" github and gh means convert to github, fastgit and fg means convert to fastgit" +
208-
"SYNTAX\n" +
209-
" fgit conv [--help|-h]\n" +
210-
" fgit conv [github|gh|fastgit|fg]\n" +
211-
"ALIASES\n" +
212-
" fgit convert\n" +
213-
"EXAMPLE\n" +
214-
" fgit conv gh")
205+
conv("-h")
215206
}
216207
os.Exit(0)
217208
case "-v", "--version", "version":

0 commit comments

Comments
 (0)