| 37 | ) |
| 38 | |
| 39 | func main() { |
| 40 | // Plug in Var flags |
| 41 | flag.Var(flagClaims, "claim", "add additional claims. may be used more than once") |
| 42 | flag.Var(flagHead, "header", "add additional header params. may be used more than once") |
| 43 | |
| 44 | // Usage message if you ask for -help or if you mess up inputs. |
| 45 | flag.Usage = func() { |
| 46 | fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) |
| 47 | fmt.Fprintf(os.Stderr, " One of the following flags is required: sign, verify or show\n") |
| 48 | flag.PrintDefaults() |
| 49 | } |
| 50 | |
| 51 | // Parse command line options |
| 52 | flag.Parse() |
| 53 | |
| 54 | // Do the thing. If something goes wrong, print error to stderr |
| 55 | // and exit with a non-zero status code |
| 56 | if err := start(); err != nil { |
| 57 | fmt.Fprintf(os.Stderr, "Error: %v\n", err) |
| 58 | os.Exit(1) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Figure out which thing to do and then do that |
| 63 | func start() error { |