| 1 |
// Copyright (c) 2014-2019 Ludovic Fauvet |
| 2 |
// Licensed under the MIT license |
| 3 |
|
| 4 |
package core |
| 5 |
|
| 6 |
import ( |
| 7 |
"flag" |
| 8 |
"os" |
| 9 |
) |
| 10 |
|
| 11 |
var ( |
| 12 |
Daemon bool |
| 13 |
Debug bool |
| 14 |
Monitor bool |
| 15 |
ConfigFile string |
| 16 |
CpuProfile string |
| 17 |
PidFile string |
| 18 |
RunLog string |
| 19 |
RPCPort uint |
| 20 |
RPCHost string |
| 21 |
RPCPassword string |
| 22 |
RPCAskPass bool |
| 23 |
NArg int |
| 24 |
) |
| 25 |
|
| 26 |
func Parseflags() { |
| 27 |
flag.BoolVar(&Debug, "debug", false, "Debug mode") |
| 28 |
flag.StringVar(&CpuProfile, "cpuprofile", "", "write cpu profile to file") |
| 29 |
flag.UintVar(&RPCPort, "p", 3390, "Server port") |
| 30 |
flag.StringVar(&RPCHost, "h", "localhost", "Server host") |
| 31 |
flag.StringVar(&RPCPassword, "P", "", "Server password") |
| 32 |
flag.BoolVar(&RPCAskPass, "a", false, "Ask for server password") |
| 33 |
flag.Parse() |
| 34 |
NArg = flag.NArg() |
| 35 |
|
| 36 |
daemon := flag.NewFlagSet("daemon", flag.ExitOnError) |
| 37 |
daemon.BoolVar(&Debug, "debug", false, "Debug mode") |
| 38 |
daemon.StringVar(&CpuProfile, "cpuprofile", "", "write cpu profile to file") |
| 39 |
daemon.StringVar(&ConfigFile, "config", "", "Path to the config file") |
| 40 |
daemon.BoolVar(&Monitor, "monitor", true, "Enable the background mirrors monitor") |
| 41 |
daemon.StringVar(&PidFile, "p", "", "Path to pid file") |
| 42 |
daemon.StringVar(&RunLog, "log", "", "File to output logs (default: stderr)") |
| 43 |
|
| 44 |
if len(os.Args) > 1 && os.Args[1] == "daemon" { |
| 45 |
Daemon = true |
| 46 |
daemon.Parse(os.Args[2:]) |
| 47 |
} |
| 48 |
} |