* Parse a Boolean from an optarg. */
| 216 | * Parse a Boolean from an optarg. |
| 217 | */ |
| 218 | static bool parseBoolOptArg(const char *option, const char *optarg) |
| 219 | { |
| 220 | if (optarg == nullptr) |
| 221 | return true; |
| 222 | if (strcmp(optarg, "true") == 0 || strcmp(optarg, "1") == 0) |
| 223 | return true; |
| 224 | else if (strcmp(optarg, "false") == 0 || strcmp(optarg, "0") == 0) |
| 225 | return false; |
| 226 | error("failed to parse argument \"%s\" for the `%s' option; " |
| 227 | "expected a Boolean [true, false]", option, optarg); |
| 228 | } |
| 229 | |
| 230 | /* |
| 231 | * Usage. |
no test coverage detected