Feat: add --datapath flag for custom data folder
This commit is contained in:
parent
440aef863b
commit
1271c8c4e2
15
main.go
15
main.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -14,6 +15,8 @@ import (
|
|||||||
"v2ray.com/core/app/router"
|
"v2ray.com/core/app/router"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var dataPath = flag.String("datapath", "", "Path to the data folder")
|
||||||
|
|
||||||
type Entry struct {
|
type Entry struct {
|
||||||
Type string
|
Type string
|
||||||
Value string
|
Value string
|
||||||
@ -216,7 +219,15 @@ func ParseList(list *List, ref map[string]*List) (*ParsedList, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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 {
|
if err != nil {
|
||||||
fmt.Println("Failed: ", err)
|
fmt.Println("Failed: ", err)
|
||||||
return
|
return
|
||||||
@ -263,5 +274,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
if err := ioutil.WriteFile("dlc.dat", protoBytes, 0777); err != nil {
|
if err := ioutil.WriteFile("dlc.dat", protoBytes, 0777); err != nil {
|
||||||
fmt.Println("Failed: ", err)
|
fmt.Println("Failed: ", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("dlc.dat has been generated successfully.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user