Skip to content

Commit a69865a

Browse files
CopilotbergmeisterCopilot
authored
Document Invoke-Formatter confirmation parameters (#2232)
* Document formatter confirmation parameters Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> * Handle pipeline binding help values in tests Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> * Clarify -Confirm and -WhatIf parameter descriptions Updated descriptions for -Confirm and -WhatIf parameters to clarify their effects when using the Path and ScriptDefinition options. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> Co-authored-by: Christoph Bergmeister <c.bergmeister@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ab19dd5 commit a69865a

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎Tests/Engine/ModuleHelp.Tests.ps1‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,14 @@ Describe 'Cmdlet parameter help' {
229229
foreach($parameterAttribute in $parameter.Attributes) {
230230
if ($parameterAttribute.ValueFromPipeline -eq $null) { continue }
231231

232-
$parameterHelpPipelineInput = if ($parameterHelp.pipelineInput -eq 'True (ByPropertyName, ByValue)') {
233-
$true
234-
}
235-
else {
236-
[System.Boolean]::Parse($parameterHelp.pipelineInput)
237-
}
232+
$parameterHelpPipelineInput = $parameterHelp.pipelineInput -eq 'True' -or $parameterHelp.pipelineInput -match 'ByPropertyName'
238233

239234
$parameterHelpPipelineInput | Should -Be $parameterAttribute.ValueFromPipelineByPropertyName `
240235
-Because "Parameter $parameterName of command $CommandName and parameter set $($parameterAttribute.ParameterSetName) has correct ValueFromPipelineByPropertyName attribute"
241236

242-
if ($parameterHelp.pipelineInput -eq 'True (ByPropertyName, ByValue)') {
243-
$parameterAttribute.ValueFromPipeline | Should -BeTrue `
244-
-Because "Parameter $parameterName of command $CommandName and parameter set $($parameterAttribute.ParameterSetName) has correct ValueFromPipeline attribute"
245-
}
237+
$parameterHelpPipelineInput = $parameterHelp.pipelineInput -match 'ByValue'
238+
$parameterHelpPipelineInput | Should -Be $parameterAttribute.ValueFromPipeline `
239+
-Because "Parameter $parameterName of command $CommandName and parameter set $($parameterAttribute.ParameterSetName) has correct ValueFromPipeline attribute"
246240
}
247241
}
248242

‎docs/Cmdlets/Invoke-Formatter.md‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Formats script text or a file based on the input settings or default settings.
1616

1717
```
1818
Invoke-Formatter [-ScriptDefinition] <string> [[-Settings] <Object>] [[-Range] <int[]>]
19-
[<CommonParameters>]
19+
[-WhatIf] [-Confirm] [<CommonParameters>]
2020
Invoke-Formatter -Path <string> [[-Settings] <Object>] [[-Range] <int[]>]
21-
[<CommonParameters>]
21+
[-WhatIf] [-Confirm] [<CommonParameters>]
2222
```
2323

2424
## DESCRIPTION
@@ -168,6 +168,41 @@ Accept pipeline input: True
168168
Accept wildcard characters: False
169169
```
170170

171+
### -Confirm
172+
173+
Prompts you for confirmation before writing changes to a file specified by **Path**. This parameter
174+
has no effect when **ScriptDefinition** is used.
175+
176+
```yaml
177+
Type: SwitchParameter
178+
Parameter Sets: (All)
179+
Aliases: cf
180+
181+
Required: False
182+
Position: Named
183+
Default value: False
184+
Accept pipeline input: False
185+
Accept wildcard characters: False
186+
```
187+
188+
### -WhatIf
189+
190+
Shows which files specified by **Path** would be changed without writing them. Formatting still
191+
runs and the formatted text is returned. This parameter has no effect when **ScriptDefinition** is
192+
used.
193+
194+
```yaml
195+
Type: SwitchParameter
196+
Parameter Sets: (All)
197+
Aliases: wi
198+
199+
Required: False
200+
Position: Named
201+
Default value: False
202+
Accept pipeline input: False
203+
Accept wildcard characters: False
204+
```
205+
171206
### CommonParameters
172207

173208
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,

0 commit comments

Comments
 (0)