diff --git a/main.go b/main.go index 58949fb7..22799f64 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "bufio" "errors" + "flag" "fmt" "io/ioutil" "os" @@ -14,6 +15,8 @@ import ( "v2ray.com/core/app/router" ) +var dataPath = flag.String("datapath", "", "Path to the data folder") + type Entry struct { Type string Value string @@ -216,7 +219,15 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) { } func main() { - dir, err := DetectPath(os.Getenv("GOPATH")) + flag.Parse() + + var dir string + var err error + if *dataPath != "" { + dir = *dataPath + } else { + dir, err = DetectPath(os.Getenv("GOPATH")) + } if err != nil { fmt.Println("Failed: ", err) return @@ -263,5 +274,7 @@ func main() { } if err := ioutil.WriteFile("dlc.dat", protoBytes, 0777); err != nil { fmt.Println("Failed: ", err) + } else { + fmt.Println("dlc.dat has been generated successfully.") } }