Required arguments#30
Conversation
|
|
||
| while (args_iterator.next()) |item| { | ||
| // Create map for required arguments | ||
| var required_map = std.StringHashMap(bool).init(allocator); |
There was a problem hiding this comment.
Can you replace the StringHashMap with a std.EnumSet? As we know all possible fields, we can use std.meta.FieldEnum instead of runtime allocation
There was a problem hiding this comment.
I'm having some trouble using the EnumSet. How do you get a proper enum to insert in this set from a field? Also, how would this work with the required items for the tagged enum of the Verb set, do we need a set per verb?
There was a problem hiding this comment.
How do you get a proper enum to insert in this set from a field?
const Fields = std.meta.FieldEnum(Type);
const field_member = @field(Fields, field.name);
set.insert(field_member);Also, how would this work with the required items for the tagged enum of the Verb set, do we need a set per verb?
Yes, but that would not hurt much, as we have to process the verb separately anyways. As we only process more errors when mandatory verb parameters are missing, this should not be much of a problem
Added option to not set the default argument of a struct variable, to make it required. Also got rid of the 'found' variable by using a blocked while.