+static void opt_check_required(struct opt_context *oc)
+{
+ for (int i = 0; i < oc->opt_count; i++) {
+ struct opt_precomputed *opt = &oc->opts[i];
+ if (!opt->count && (opt->flags & OPT_REQUIRED)) {
+ struct opt_item *item = opt->item;
+ if (item->letter > OPT_POSITIONAL_TAIL)
+ opt_failure("Required positional argument #%d not found.", i - OPT_POSITIONAL_TAIL);
+ else if (item->letter == OPT_POSITIONAL_TAIL)
+ opt_failure("Required positional argument not found.");
+ else if (item->letter && item->name)
+ opt_failure("Required option -%c/--%s not found.", item->letter, item->name);
+ else if (item->letter)
+ opt_failure("Required option -%c not found.", item->letter);
+ else
+ opt_failure("Required option --%s not found.", item->name);
+ }
+ }
+}
+