mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 07:05:06 +03:00
Move yggdrasil command line env to separate file
This commit is contained in:
parent
cbb6dc1b7d
commit
7b437a1dcd
3 changed files with 68 additions and 63 deletions
45
cmd/yggdrasil/cmd_line_env.go
Normal file
45
cmd/yggdrasil/cmd_line_env.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import "flag"
|
||||
|
||||
type CmdLineEnv struct {
|
||||
genconf bool
|
||||
useconf bool
|
||||
useconffile string
|
||||
normaliseconf bool
|
||||
confjson bool
|
||||
autoconf bool
|
||||
ver bool
|
||||
logto string
|
||||
getaddr bool
|
||||
getsnet bool
|
||||
loglevel string
|
||||
}
|
||||
|
||||
func (cmdLineEnv *CmdLineEnv) parseFlagsAndArgs() {
|
||||
genconf := flag.Bool("genconf", false, "print a new config to stdout")
|
||||
useconf := flag.Bool("useconf", false, "read HJSON/JSON config from stdin")
|
||||
useconffile := flag.String("useconffile", "", "read HJSON/JSON config from specified file path")
|
||||
normaliseconf := flag.Bool("normaliseconf", false, "use in combination with either -useconf or -useconffile, outputs your configuration normalised")
|
||||
confjson := flag.Bool("json", false, "print configuration from -genconf or -normaliseconf as JSON instead of HJSON")
|
||||
autoconf := flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)")
|
||||
ver := flag.Bool("version", false, "prints the version of this build")
|
||||
logto := flag.String("logto", "stdout", "file path to log to, \"syslog\" or \"stdout\"")
|
||||
getaddr := flag.Bool("address", false, "returns the IPv6 address as derived from the supplied configuration")
|
||||
getsnet := flag.Bool("subnet", false, "returns the IPv6 subnet as derived from the supplied configuration")
|
||||
loglevel := flag.String("loglevel", "info", "loglevel to enable")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
cmdLineEnv.genconf = *genconf
|
||||
cmdLineEnv.useconf = *useconf
|
||||
cmdLineEnv.useconffile = *useconffile
|
||||
cmdLineEnv.normaliseconf = *normaliseconf
|
||||
cmdLineEnv.confjson = *confjson
|
||||
cmdLineEnv.autoconf = *autoconf
|
||||
cmdLineEnv.ver = *ver
|
||||
cmdLineEnv.logto = *logto
|
||||
cmdLineEnv.getaddr = *getaddr
|
||||
cmdLineEnv.getsnet = *getsnet
|
||||
cmdLineEnv.loglevel = *loglevel
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue