Can't pipe Get-PlasterTemplate into Invoke-Plaster
DarqueWarrior opened this issue · comments
On my first attempt to use Plaster I tried
Get-PlasterTemplate | select -Skip 1 | Invoke-Plaster -DestinationPath r:\temp
And I was prompted for the TemplatePath anyway which was very odd. I reviewed the repo and saw the TemplatePath parameter was not marked with ValueFromPipelineByPropertyName=$true. That cleared up why it did not work but I felt it should so I cloned the repo to start to add it.
That is when I realized all the code is in the begin block and pipeline parameters are not passed to begin only process and end. When I added close brace on line 157 and process { on line 159 everything now works as expected and you can pipe Get-PlasterTemplate into Invoke-Plaster.
I had never seen a method that only used begin so instead of submitting a pull request I figured I should log an issue so someone could explain to me why this was done and if what I have done is a safe change.
AFAIK, there wasn't a reason for it and a PR would be awesome fixing this!
Just want to hear what @rkeithhill has to say first
Sweet I will submit my change for review.
The bulk of the "shared functions" are in the begin block. They are defined there and used later in the end block. There is some imperative code in begin that could be moved to a process block. Just keep in mind that pipelining was not the primary scenario for Plaster. What we wanted to make sure that worked (just like Yeoman) is that the user could specify a template path, Plaster would read that and then prompt for the various bits of info the template author needs from the user. But we also wanted to support fully automated scenarios where the user could supply all the required template info via dynamic parameters. If we support pipeline input, then we must make sure those two scenarios work. I feel good about the first one (interactive prompting). I'm not as sure about the second scenario involving dynamic parameters.
OK, I just submitted a PR with the change for review. I have been using my version and everything works as expected. I only wanted to pipe in the Template path not all the prompting for input (which still happens).
But does the dynamic parameter support still work e.g.:
Get-PlasterTemplate | select -Skip 1 | Invoke-Plaster -DestinationPath r:\temp -Author Jon -Version 0.1.0 -Editor VSCode
Note: Use whatever parameter names are defined in the template you're using.