Skip to content

Commit

Permalink
add help aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jpawlowski committed Aug 31, 2024
1 parent 7ba5a86 commit c52d9ff
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/powershell-extended/Invoke-NerdFontInstaller.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<#PSScriptInfo
.VERSION 1.2.0
.VERSION 1.2.1
.GUID a3238c59-8a0e-4c11-a334-f071772d1255
Expand All @@ -25,8 +25,10 @@
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
Version 1.2.0 (2024-08-31)
Version 1.2.1 (2024-08-31)
- Add -Help and -Version parameters to allow help for dynamic Name parameter and when running the script directly from the web.
- Add alias for -Help parameter to allow using '?', 'help', and '--help' as special Name parameter values.
- Add alias for -Version parameter to allow using 'version', 'ver', and '--version' as special Name parameter values.
#>

<#
Expand Down Expand Up @@ -249,7 +251,7 @@ param(
[System.Management.Automation.CompletionResult]::new($_.Key, $_.Key, 'ParameterValue', $_.Value)
}
})]
[string]$Help = 'Summary',
[string]$Help = 'Help',

[Parameter(Mandatory = $true, ParameterSetName = 'Version')]
[switch]$Version
Expand Down Expand Up @@ -499,7 +501,13 @@ param(`$commandName, `$parameterName, `$wordToComplete, `$commandAst, `$fakeBoun
}

begin {
if ($PSBoundParameters.ContainsKey('Help')) {
if (
$PSBoundParameters.ContainsKey('Help') -or
(
$PSBoundParameters.Name.Count -eq 1 -and
@('help', '--help', '?') -contains $PSBoundParameters.Name[0]
)
) {
try {
if ($null -eq $PSCommandPath -or $PSCommandPath -eq '') {
$scriptContent = $MyInvocation.MyCommand.ScriptBlock.ToString()
Expand Down Expand Up @@ -595,7 +603,13 @@ begin {
return
}

if ($Version) {
if (
$Version -or
(
$PSBoundParameters.Name.Count -eq 1 -and
@('version', '--version', 'ver') -eq $PSBoundParameters.Name[0]
)
) {
$scriptContent = $MyInvocation.MyCommand.ScriptBlock.ToString()
$versionNumber = $null
$inHelpBlock = $false
Expand Down

0 comments on commit c52d9ff

Please sign in to comment.