Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Remove-Template command #31

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pecan-waffle.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,31 @@ function New-PWItem{
}
Set-Alias Add-Item New-PWItem -Description 'obsolete: This was added for back compat and will be removed soon'

function Remove-PWTemplate{
[cmdletbinding()]
param(
[Parameter(Position=1,Mandatory=$true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add ValueFromPipeline=$true here? This will enable piping for example

'aspnet-empty`,`aspnet-web` | Remove-PWTemplate

[ValidateNotNullOrEmpty()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to remove this validation and then just skip empty values in TemplateNames. This works better for the pipeline as well.

[string[]]$TemplateNames
)
process{

<# Make a copy of the old template array #>
$templates = $Global:pecanwafflesettings.Templates

<# Create new template array #>
$Global:pecanwafflesettings.Templates = @()

<# Filter out templates #>
foreach($template in $templates){
if($TemplateNames -notcontains $template.Name){
$Global:pecanwafflesettings.Templates += $template
}
}
}
}
Set-Alias Remove-Template Remove-PWTemplate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you add this because of the other set-alias elements in this file? Those are mostly there for back compat with an earlier version of the script. I think it's best to use the pattern name-PWName pattern. So I think we could get rid of this alias here.


function InternalGet-EvaluatedPropertiesFrom{
[cmdletbinding()]
param(
Expand Down