=Added powershell-pipeline functionality to ha cmdlets
This commit is contained in:
parent
47f27cb1f5
commit
10b670269a
|
@ -1,5 +1,7 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[Alias('Slug')]
|
||||
[string[]]$AddOnSlug,
|
||||
[Alias('Name')]
|
||||
[string[]]$AddOnName,
|
||||
[switch]$InspectContainer,
|
||||
[switch]$NoPatternMatch,
|
||||
|
@ -14,7 +16,7 @@ $addons = $addons.data.addons
|
|||
switch( $Status ) {
|
||||
'Installed' { $addons = $addons | Where-Object Installed }
|
||||
'NotInstalled' { $addons = $addons | Where-Object -Not Installed }
|
||||
'Running' {
|
||||
default {
|
||||
$addons = $addons | Where-Object Installed
|
||||
$InspectContainer = $true
|
||||
}
|
||||
|
@ -49,7 +51,7 @@ switch( $Status ) {
|
|||
$addons = $addons | Where-Object Status -eq 'running'
|
||||
}
|
||||
'Stopped' {
|
||||
$addons = $addons | Where-Object Status -eq 'running'
|
||||
$addons = $addons | Where-Object Status -ne 'running'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,23 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
|
||||
[Alias('Slug')]
|
||||
[string[]]$AddOnSlug,
|
||||
[switch]$NoPatternMatch
|
||||
)
|
||||
|
||||
Get-HA_Addon 'Installed' -AddOnSlug:$AddOnSlug -NoPatternMatch:$NoPatternMatch | ForEach-Object {
|
||||
Invoke-HomeAssistantCli addons start $_.slug
|
||||
begin{}
|
||||
process{
|
||||
foreach( $slug in $AddOnSlug ) {
|
||||
Get-HA_Addon 'Running' -AddOnSlug:$slug -NoPatternMatch:$NoPatternMatch | ForEach-Object {
|
||||
$local:a = $_
|
||||
$local:invocation = Invoke-HomeAssistantCli addons start $a.slug
|
||||
Get-HA_Addon -InspectContainer -NoPatternMatch -AddOnSlug $a.slug |
|
||||
Select-Object @{
|
||||
L='result';E={$invocation.result}
|
||||
},@{
|
||||
L='data';E={$invocation.data}
|
||||
},*
|
||||
}
|
||||
}
|
||||
}
|
||||
end{}
|
||||
|
|
|
@ -1,8 +1,23 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]
|
||||
[Alias('Slug')]
|
||||
[string[]]$AddOnSlug,
|
||||
[switch]$NoPatternMatch
|
||||
)
|
||||
|
||||
Get-HA_Addon 'Running' -AddOnSlug:$AddOnSlug -NoPatternMatch:$NoPatternMatch | ForEach-Object {
|
||||
Invoke-HomeAssistantCli addons stop $_.slug
|
||||
begin{}
|
||||
process{
|
||||
foreach( $slug in $AddOnSlug ) {
|
||||
Get-HA_Addon 'Running' -AddOnSlug:$slug -NoPatternMatch:$NoPatternMatch | ForEach-Object {
|
||||
$local:a = $_
|
||||
$local:invocation = Invoke-HomeAssistantCli addons stop $a.slug
|
||||
Get-HA_Addon -InspectContainer -NoPatternMatch -AddOnSlug $a.slug |
|
||||
Select-Object @{
|
||||
L='result';E={$invocation.result}
|
||||
},@{
|
||||
L='data';E={$invocation.data}
|
||||
},*
|
||||
}
|
||||
}
|
||||
}
|
||||
end{}
|
||||
|
|
Loading…
Reference in New Issue