| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | ) |
| 7 | |
| 8 | func main() { |
| 9 | |
| 10 | var args []string |
| 11 | cmd := "-h" |
| 12 | if len(os.Args) > 1 { |
| 13 | cmd = os.Args[1] |
| 14 | } |
| 15 | if len(os.Args) > 2 { |
| 16 | args = os.Args[2:] |
| 17 | } |
| 18 | |
| 19 | switch cmd { |
| 20 | case "oss-fuzz-corpus": |
| 21 | ossFuzzCorpusSubCommand(args) |
| 22 | case "unicode-case-folding-map": |
| 23 | unicodeCaseFoldingMapSubCommand(args) |
| 24 | case "emb-structs": |
| 25 | embStructsSubCommand(args) |
| 26 | case "-h": |
| 27 | fallthrough |
| 28 | default: |
| 29 | fmt.Fprintf(os.Stderr, `Usage: _tools <subcommand> [options] |
| 30 | subcommands: |
| 31 | oss-fuzz-corpus |
| 32 | unicode-case-folding-map |
| 33 | emb-structs |
| 34 | `) |
| 35 | os.Exit(1) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func usage(u func(), err error) { |
| 40 | u() |
| 41 | if err != nil { |
| 42 | fmt.Fprint(os.Stderr, err) |
| 43 | } |
| 44 | os.Exit(1) |
| 45 | } |