1- package main
1+ package oper
22
33import (
4+ "fgit-go/shared"
45 "fmt"
56 "os"
67 "path"
@@ -24,7 +25,7 @@ func (g *GetFunc) Run(args []string) {
2425
2526func get (url , fpath string ) {
2627 if url == "" || url == "--help" || url == "-h" {
27- fmt .Println (getHelpMsg )
28+ fmt .Println (shared . GetHelpMsg )
2829 } else {
2930 getFile (url , fpath )
3031 }
@@ -34,13 +35,13 @@ func getFile(url, fpath string) {
3435 urlSplit := strings .Split (url , "/" )
3536 filename := urlSplit [len (urlSplit )- 1 ]
3637 if fpath == "" {
37- downloadFile (url , filename )
38+ shared . DownloadFile (url , filename )
3839 }
3940
40- if isExists (fpath ) {
41- if isDir (fpath ) {
41+ if shared . IsExists (fpath ) {
42+ if shared . IsDir (fpath ) {
4243 fpath = path .Join (fpath , filename )
43- downloadFile (url , fpath )
44+ shared . DownloadFile (url , fpath )
4445 } else {
4546 isContinue := ' '
4647 fmt .Print (
@@ -68,14 +69,14 @@ func getFile(url, fpath string) {
6869
6970 fmt .Println ("Redirect ->" , url )
7071
71- newURL := strings .Replace (url , "https://github.com" , downloadMirror , - 1 )
72+ newURL := strings .Replace (url , "https://github.com" , shared . DownloadMirror , - 1 )
7273 if newURL != url {
7374 fmt .Println ("Redirect ->" , newURL )
7475 }
7576 fmt .Println ("File ->" , fpath )
7677 fmt .Println ("Downloading..." )
7778
78- downloadFile (newURL , fpath )
79+ shared . DownloadFile (newURL , fpath )
7980
8081 fmt .Println ("Finished." )
8182}
@@ -84,15 +85,15 @@ func parseToGetUrl(url string) string {
8485 if ! strings .HasPrefix (url , "https://github.com/" ) {
8586 return url
8687 }
87- query := replacePrefix (url , "https://github.com/" , "" )
88+ query := shared . ReplacePrefix (url , "https://github.com/" , "" )
8889
8990 querySplit := strings .Split (query , "/" )
9091
9192 if len (querySplit ) > 3 {
9293 // Source -> fastgitorg/fgit-go/blob/master/fgit.go
9394 // Target -> fastgitorg/fgit-go/master/fgit.go
9495 if querySplit [2 ] == "blob" {
95- url = rawMirror
96+ url = shared . RawMirror
9697 for _i , _s := range querySplit {
9798 if _i != 2 {
9899 url += "/" + _s
0 commit comments