| 156 | } |
| 157 | |
| 158 | bool CommandLine::show_errors(const char *context) { |
| 159 | int errors = 0; |
| 160 | if (!positional_used) |
| 161 | for (auto &&po : positional) { |
| 162 | printf("Positional argument '%s' %s\n", po, context ? context : "are not allowed"); |
| 163 | errors += 1; |
| 164 | } |
| 165 | for (auto &&op : options) { |
| 166 | if (!op.used) { |
| 167 | printf("Command line option %s %s\n", op.key.data, |
| 168 | !op.in_help ? "has no meaning (typo?)" : context ? context : "cannot be used in this context"); |
| 169 | errors += 1; |
| 170 | } |
| 171 | if (op.wrong_type_message) { |
| 172 | printf("Command line option %s %s\n", op.key.data, op.wrong_type_message); |
| 173 | errors += 1; |
| 174 | } |
| 175 | } |
| 176 | return errors != 0; |
| 177 | } |
| 178 | |
| 179 | static const char TOY_USAGE[] = |
| 180 | R"(toy <version>. |
no outgoing calls