You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
When you create a new generator, you may wind up adding new command line functionality based on what the generator produces. For example, the 'chef repo' generator has a --policy-only flag, which probably only makes sense for that particular generator.
When you add them, you need to touch a couple of places:
The option itself goes in the generator class
The generator context needs to be added in lib/chef-dk/generator.rb
The new context method needs to be proxied into the template helper.
The value needs to be set in the new generator classes setup_context method
I propose we add some sugar to take the CLI options passed to the generator and automatically add them to the context and proxy via the global setup context. That way you can just map the option name to the context object.
Essentially, we add a bit of sugar to add methods to the Generator context and make sure they are proxied from the TemplateHelper, and then walk the config hash, adding items to the context dynamically.
The text was updated successfully, but these errors were encountered:
This all seems reasonable to me. In terms of the implementation (and I think this is what you were getting at), I'd prefer to stick with implementation choices that surface errors as quickly and clearly as possible. That's why I originally chose to use template helpers rather than variables; a misspelled instance variable is a warning (that you never see unless you run ruby -w) whereas a misspelled method name is an error. So something like:
classMySplendidGenerator < InheritsFromThing# really verbose method name for demonstration purposesoption_that_threads_to_template_context:policy_only,# other mixlib-cli stuffend
That could, I think, accomplish tasks 1-4 while still keeping the "rightness" or "wrongness" of your code as binary as possible (i.e., minimize opportunities for silent failures).
When you create a new generator, you may wind up adding new command line functionality based on what the generator produces. For example, the 'chef repo' generator has a --policy-only flag, which probably only makes sense for that particular generator.
When you add them, you need to touch a couple of places:
I propose we add some sugar to take the CLI options passed to the generator and automatically add them to the context and proxy via the global setup context. That way you can just map the option name to the context object.
Essentially, we add a bit of sugar to add methods to the Generator context and make sure they are proxied from the TemplateHelper, and then walk the config hash, adding items to the context dynamically.
The text was updated successfully, but these errors were encountered: