mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-15 19:22:53 +08:00
feature: add environs startup option support (#2909)
This commit is contained in:
parent
81bbbe4eec
commit
98df77439c
22
main.go
22
main.go
|
@ -21,7 +21,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
flagset map[string]bool
|
||||
version bool
|
||||
testConfig bool
|
||||
geodataMode bool
|
||||
|
@ -33,20 +32,15 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&homeDir, "d", "", "set configuration directory")
|
||||
flag.StringVar(&configFile, "f", "", "specify configuration file")
|
||||
flag.StringVar(&externalUI, "ext-ui", "", "override external ui directory")
|
||||
flag.StringVar(&externalController, "ext-ctl", "", "override external controller address")
|
||||
flag.StringVar(&secret, "secret", "", "override secret for RESTful API")
|
||||
flag.StringVar(&homeDir, "d", os.Getenv("CLASH_HOME_DIR"), "set configuration directory")
|
||||
flag.StringVar(&configFile, "f", os.Getenv("CLASH_CONFIG_FILE"), "specify configuration file")
|
||||
flag.StringVar(&externalUI, "ext-ui", os.Getenv("CLASH_OVERRIDE_EXTERNAL_UI_DIR"), "override external ui directory")
|
||||
flag.StringVar(&externalController, "ext-ctl", os.Getenv("CLASH_OVERRIDE_EXTERNAL_CONTROLLER"), "override external controller address")
|
||||
flag.StringVar(&secret, "secret", os.Getenv("CLASH_OVERRIDE_SECRET"), "override secret for RESTful API")
|
||||
flag.BoolVar(&geodataMode, "m", false, "set geodata mode")
|
||||
flag.BoolVar(&version, "v", false, "show current version of clash")
|
||||
flag.BoolVar(&testConfig, "t", false, "test configuration and exit")
|
||||
flag.Parse()
|
||||
|
||||
flagset = map[string]bool{}
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
flagset[f.Name] = true
|
||||
})
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -99,13 +93,13 @@ func main() {
|
|||
}
|
||||
|
||||
var options []hub.Option
|
||||
if flagset["ext-ui"] {
|
||||
if externalUI != "" {
|
||||
options = append(options, hub.WithExternalUI(externalUI))
|
||||
}
|
||||
if flagset["ext-ctl"] {
|
||||
if externalController != "" {
|
||||
options = append(options, hub.WithExternalController(externalController))
|
||||
}
|
||||
if flagset["secret"] {
|
||||
if secret != "" {
|
||||
options = append(options, hub.WithSecret(secret))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user