GeezerVison is showing github.com — Display full help with 'help' function (#5195) · PowerShell/PowerShell@c781959
File tree
Expand file treeCollapse file tree
Open diff view settings
src/System.Management.Automation/engine test/powershell/engine/Help
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/System.Management.Automation/engine/InitialSessionState.cs +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4253,6 +4253,11 @@ .FORWARDHELPCATEGORY Cmdlet |
4253 | 4253 | [switch] |
4254 | 4254 | ${ShowWindow}) |
4255 | 4255 |
|
| 4256 | + # Display the full help topic by default but only for the AllUsersView parameter set. |
| 4257 | + if (($psCmdlet.ParameterSetName -eq 'AllUsersView') -and !$Full) { |
| 4258 | + $PSBoundParameters['Full'] = $true |
| 4259 | + } |
| 4260 | +
|
4256 | 4261 | #Set the outputencoding to Console::OutputEncoding. More.com doesn't work well with Unicode. |
4257 | 4262 | $outputEncoding=[System.Console]::OutputEncoding |
4258 | 4263 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: test/powershell/engine/Help/HelpSystem.Tests.ps1 +17-1Lines changed: 17 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -278,7 +278,7 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { |
278 | 278 | } |
279 | 279 | } |
280 | 280 |
|
281 | | - Describe "Get-Help should find pattern alias" -Tags "CI" { |
| 281 | +Describe "Get-Help should find pattern alias" -Tags "CI" { |
282 | 282 | # Remove test alias |
283 | 283 | AfterAll { |
284 | 284 | Remove-Item alias:\testAlias1 -ErrorAction SilentlyContinue |
@@ -300,5 +300,21 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { |
300 | 300 | $help.Category | Should BeExactly "Alias" |
301 | 301 | $help.Synopsis | Should BeExactly "Where-Object" |
302 | 302 | } |
| 303 | +} |
| 304 | + |
| 305 | +Describe "help function uses full view by default" -Tags "CI" { |
| 306 | + It "help should return full view without -Full switch" { |
| 307 | + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process) |
| 308 | + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty |
| 309 | + } |
303 | 310 |
|
| 311 | + It "help should return full view even with -Full switch" { |
| 312 | + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Full) |
| 313 | + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty |
| 314 | + } |
| 315 | + |
| 316 | + It "help should not append -Full when not using AllUsersView parameter set" { |
| 317 | + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Parameter Name) |
| 318 | + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should BeNullOrEmpty |
| 319 | + } |
304 | 320 | } |