cmd: add functions to report option/arg errors to the public API

This commit is contained in:
2025-07-17 17:56:00 +01:00
parent 92ccc5626d
commit 5d6423057a
6 changed files with 498 additions and 195 deletions

View File

@@ -231,3 +231,22 @@ void z__b_get_option_usage_string(
}
}
}
struct b_command_arg *b_command_option_get_arg_with_id(
struct b_command_option *opt, unsigned int id)
{
b_queue_iterator it;
b_queue_foreach (&it, &opt->opt_args) {
struct b_command_arg *arg
= b_unbox(struct b_command_arg, it.entry, arg_entry);
if (!arg) {
continue;
}
if (arg->arg_id == id) {
return arg;
}
}
return NULL;
}