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

Commit 9a72c4c

Browse files
authored
[flag] add -h && finish #6
1 parent c69145a commit 9a72c4c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

fgit.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func debug(url string) bool {
4242
fmt.Println("" +
4343
"FastGit Debug Command Line Tool\n" +
4444
"===============================")
45-
if url != "--help" {
45+
if url != "--help" && url != "-h" {
4646
fmt.Println("Remote Address:", url)
4747
fmt.Print("IP Address: ")
4848
addr, err := net.LookupIP(strings.Replace(strings.Replace(url, "https://", "", -1), "http://", "", -1))
@@ -70,7 +70,7 @@ func debug(url string) bool {
7070
} else {
7171
fmt.Println("" +
7272
"SYNTAX\n" +
73-
" fgit debug [URL<string>] [--help]\n" +
73+
" fgit debug [URL<string>] [--help|-h]\n" +
7474
"REMARKS\n" +
7575
" URL is an optional parameter\n" +
7676
" We debug https://hub.fastgit.org by default\n" +
@@ -120,7 +120,7 @@ func checkErr(err error, msg string, exitCode int) {
120120
}
121121

122122
func main() {
123-
if len(os.Args) == 1 || (len(os.Args) == 2 && os.Args[1] == "--help") {
123+
if len(os.Args) == 1 || (len(os.Args) == 2 && (os.Args[1] == "--help" || os.Args[1] == "-h")) {
124124
fmt.Println("" +
125125
"FastGit Command Line Tool\n" +
126126
"=========================\n" +
@@ -171,6 +171,28 @@ func main() {
171171
os.Exit(0)
172172
}
173173

174+
if os.Args[1] == "conv" || os.Args[1] == "convert" {
175+
switch len(os.Args) {
176+
default:
177+
// TODO: ABOUT.CONVERT
178+
case 2:
179+
switch os.Args[2] {
180+
case "gh":
181+
case "github":
182+
convertToGitHub()
183+
case "fg"
184+
case "fastgit"
185+
convertToFastGit()
186+
case "-h":
187+
case "--help":
188+
// TODO: HELP
189+
fmt.Println("Help")
190+
default:
191+
fmt.Println("Unknown args"))
192+
}
193+
os.Exit(0)
194+
}
195+
174196
for i := range os.Args {
175197
if os.Args[i] == "push" || os.Args[i] == "pull" {
176198
isPushOrPull = true
@@ -204,14 +226,14 @@ func main() {
204226
}
205227

206228
func get(url, fpath string) {
207-
if url == "" || url == "--help" {
229+
if url == "" || url == "--help" || url == "-h" {
208230
fmt.Println("" +
209231
"FastGit Get Command Line Tool\n" +
210232
"=============================\n" +
211233
"REMARKS\n" +
212234
" Download with FastGit automatically\n" +
213235
"SYNTAX\n" +
214-
" fgit [--help]\n" +
236+
" fgit [--help|-h]\n" +
215237
" fgit get [URL<string>]\n" +
216238
" fgit get [URL<string>] [Path<string>]\n" +
217239
"ALIASES\n" +

0 commit comments

Comments
 (0)