signature @dynamicMemberLookup
tanner0101 opened this issue · 0 comments
Now that SE-0252 has been accepted, we should try to adopt @dynamicMemberLookup
in ConsoleKit:
let foo = try context.option(\.foo)
// could become
let foo = context.options.foo
Conformance to @dynamicMemberLookup
should be fairly straightforward except for one issue: throwing. Since @dynamicMemberLookup
will result in a subscript / computed-property for the given key path, we will not be able to throw. To remedy this, we can insert an "input validation" step before the command actually runs. In this step, we would ensure any supplied arguments / options have been converted to their desired types and store them. Then the member lookup could be done once the command runs without throwing. (Even if we don't decide to adopt @dynamicMemberLookup
, this early validation step could be a nice addition)