break for the undefine option

This commit is contained in:
lion 2022-06-21 18:02:40 +08:00
parent 231f56b291
commit 82ed1e831e
1 changed files with 17 additions and 11 deletions

View File

@ -40,17 +40,20 @@ func testSearch() {
continue continue
} }
var eIdx = strings.Index(r, "=") var sIdx = strings.Index(r, "=")
if eIdx < 0 { if sIdx < 0 {
fmt.Printf("missing = for args pair '%s'\n", r) fmt.Printf("missing = for args pair '%s'\n", r)
return return
} }
switch r[2:eIdx] { switch r[2:sIdx] {
case "db": case "db":
dbFile = r[eIdx+1:] dbFile = r[sIdx+1:]
case "cache-policy": case "cache-policy":
cachePolicy = r[eIdx+1:] cachePolicy = r[sIdx+1:]
default:
fmt.Printf("undefined option `%s`\n", r)
return
} }
} }
@ -122,19 +125,22 @@ func testBench() {
continue continue
} }
var eIdx = strings.Index(r, "=") var sIdx = strings.Index(r, "=")
if eIdx < 0 { if sIdx < 0 {
fmt.Printf("missing = for args pair '%s'\n", r) fmt.Printf("missing = for args pair '%s'\n", r)
return return
} }
switch r[2:eIdx] { switch r[2:sIdx] {
case "db": case "db":
dbFile = r[eIdx+1:] dbFile = r[sIdx+1:]
case "src": case "src":
srcFile = r[eIdx+1:] srcFile = r[sIdx+1:]
case "cache-policy": case "cache-policy":
cachePolicy = r[eIdx+1:] cachePolicy = r[sIdx+1:]
default:
fmt.Printf("undefined option `%s`\n", r)
return
} }
} }