A module to "Decorate" a task with "Arguments" #4129
Replies: 4 comments
-
So here's what it looks like in practice:
So in my example, I'm trying to abstract out actual deployment logic from the task itself so it can be well-tested. Therefore it looks a lot cleaner, plus when I'm missing any required arguments, it tells me ALL of the arguments I'm missing at once instead of waiting for me to mess up again, one by one. |
Beta Was this translation helpful? Give feedback.
-
To add to this further, I've built a task with the documentation Builder that I'd like to incorporate into the final design. This is the output of the above task:
|
Beta Was this translation helpful? Give feedback.
-
Also, I understand I can create my own external module, but because the CakeEngine and strategies are sealed, I'm having trouble figuring out how I can override the information that gets passed through the runner. I suppose I can override the DescriptionScriptHost, and it will describe differently? |
Beta Was this translation helpful? Give feedback.
-
https://www.nuget.org/packages/Cake.Sprinkles.Module It exists now. I'd like to add this to the core library so it doesn't have to take over the one tasksetup, and would like if someone could look at it and see if they agree it's good. |
Beta Was this translation helpful? Give feedback.
-
I've been working on this myself and have a pretty good foundation of code, with test coverage...
I'd like to call it "Sprinkles", which goes on top of "Frosting". It's a "Decorator" for Properties in a task. Basically, you add attributes to a property in a task, like TaskArgumentName, and TaskArgumentIsRequired, and it uses reflection to set the value by type (For instance you could make an Int32, and it will convert the string to an Int32, or throw a descriptive Argument Error suggesting that the Argument is not a valid value based on the type).
There is stuff I want to do but can't without incorporating it into the "internal" library structure of Frosting.
One of the things I envision is a new command line argument: "--arguments", where you can have a TaskArgumentDescription attribute, and when you type in --arguments --target=YourTask, it will say:
The following argument(s) are required:
The following argument(s) are optional:
Another thought I had was whether or not it would accept deserialization of JSON strings or something -- but I think that's less important than the other stuff I mentioned.
What do you think? If you're one of the contributors that could approve of this, I would love to talk with you further, walk you through my code and changes and get any ideas for modification.
Beta Was this translation helpful? Give feedback.
All reactions