API Redesign #13
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Having used this for a while, I think the command building API should be somewhat redesigned. I'm considering two main approaches:
There's maybe a little bit more magic going on under the hood here, but it saves some redundant information (output struct field names), and there's less boilerplate than the current API. The function signatures outlined would be:
The nice thing is that there's no dynamic comptime state here.
The second style is as follows:
This does a very goofy thing by using the builder methods as type specifiers. This allows the options struct to have methods defined on it, which can be quite useful. As far as I have reasoned through it, this does have to have the dynamic state for the builder (and thus the additional boilerplate) because the
Options
type cannot be generated in order to support defining methods—since the type expressions have to result in the types that the user actually wants to use when accessing the options struct, the only way to store the metadata the parser needs is to do it dynamically in order with each field definition.Syntactically, I think this ends up being harder to read than the previous style, it has more boilerplate, and I'm really not convinced there's much value in having methods on the
Options
struct anyway. Besides, #2 provides a solution to that which is compatible with the first style anyway—rather than generating a type, allow the user to pass in a manually defined type with compatible fields.