mirror of https://github.com/v2ray/v2ray-core
Fix Test Parse flag before flag defined by V2 in main
parent
372e9411ad
commit
6f1f836a22
16
main/main.go
16
main/main.go
|
@ -27,6 +27,18 @@ var (
|
||||||
version = flag.Bool("version", false, "Show current version of V2Ray.")
|
version = flag.Bool("version", false, "Show current version of V2Ray.")
|
||||||
test = flag.Bool("test", false, "Test config file only, without launching V2Ray server.")
|
test = flag.Bool("test", false, "Test config file only, without launching V2Ray server.")
|
||||||
format = flag.String("format", "json", "Format of input file.")
|
format = flag.String("format", "json", "Format of input file.")
|
||||||
|
|
||||||
|
/* We have to do this here because Golang's Test will also need to parse flag, before
|
||||||
|
main func in this file is run.
|
||||||
|
*/
|
||||||
|
_ = func() error {
|
||||||
|
|
||||||
|
flag.Var(&configFiles, "config", "Config file for V2Ray. Multiple assign is accepted (only json). Latter ones overrides the former ones.")
|
||||||
|
flag.Var(&configFiles, "c", "Short alias of -config")
|
||||||
|
flag.StringVar(&configDir, "confdir", "", "A dir with multiple json config")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}()
|
||||||
)
|
)
|
||||||
|
|
||||||
func fileExists(file string) bool {
|
func fileExists(file string) bool {
|
||||||
|
@ -122,9 +134,7 @@ func printVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Var(&configFiles, "config", "Config file for V2Ray. Multiple assign is accepted (only json). Latter ones overrides the former ones.")
|
|
||||||
flag.Var(&configFiles, "c", "Short alias of -config")
|
|
||||||
flag.StringVar(&configDir, "confdir", "", "A dir with multiple json config")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
printVersion()
|
printVersion()
|
||||||
|
|
Loading…
Reference in New Issue