From: Jani Nikula Date: Sun, 1 Oct 2017 20:53:11 +0000 (+0300) Subject: cli: use designated initializers for opt desc X-Git-Tag: 0.26_rc0~128 X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=4a6721970a42a9f86149fb5d395d1001fed2d305;hp=4a6721970a42a9f86149fb5d395d1001fed2d305;p=notmuch cli: use designated initializers for opt desc Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output variables, where the output variable being non-NULL determines the type. Introduce checks to ensure only one is set. The downside is some waste of const space per argument; this could be saved by retaining opt_type and using a union, but that's still pretty verbose. - Fix some variables due to the type safety. Mostly a good thing, but leads to some enums being changed to ints. This is pedantically correct, but somewhat annoying. We could also cast, but that defeats the purpose a bit. - Terminate the opt desc arrays using {}. The output variable type safety and the ability to add new fields for just some output types or arguments are the big wins. For example, if we wanted to add a variable to set when the argument is present, we could do so for just the arguments that need it. Beauty is in the eye of the beholder, but I think this looks nice when defining the arguments, and reduces some of the verbosity we have there. ---