adjust flag handling

This commit is contained in:
siddontang 2015-03-21 20:31:43 +08:00
parent fb665e7773
commit 3d806ad179
1 changed files with 13 additions and 13 deletions

View File

@ -64,23 +64,23 @@ func main() {
cfg.Databases = *databases cfg.Databases = *databases
} }
// check bool flag, use it.
for _, arg := range os.Args {
arg := strings.ToLower(arg)
switch arg {
case "-rpl", "-rpl=true", "-rpl=false":
cfg.UseReplication = *rpl
case "-readonly", "-readonly=true", "-readonly=false":
cfg.Readonly = *readonly
case "-rpl_sync", "-rpl_sync=true", "-rpl_sync=false":
cfg.Replication.Sync = *rplSync
}
}
if len(*slaveof) > 0 { if len(*slaveof) > 0 {
cfg.SlaveOf = *slaveof cfg.SlaveOf = *slaveof
cfg.Readonly = true cfg.Readonly = true
cfg.UseReplication = true cfg.UseReplication = true
} else {
cfg.Readonly = *readonly
// if rpl in command flag, use it.
for _, arg := range os.Args {
arg := strings.ToLower(arg)
if arg == "-rpl" || arg == "-rpl=true" || arg == "-rpl=false" {
cfg.UseReplication = *rpl
break
}
}
cfg.Replication.Sync = *rplSync
} }
if *ttlCheck > 0 { if *ttlCheck > 0 {