Skip to content

Commit

Permalink
Merge branch 'release/v3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
joonro committed Jun 8, 2022
2 parents 19142e4 + ddbb5b4 commit 97d4a2f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ $Global:GetChildItemColorVerticalSpace = 1
* Authors
- [[http://github.com/joonro][Joon Ro]].
* Changelog
** v3.2.0
- Make ~Get-ChildItemColor~ a proxy function of ~~Get-ChildItem~, so
~Get-ChildItemColor~ supports all the parameters of the original function.
** v3.1.0
- ~Get-ChildItemColor~ only highlights names instead of highlighting the whole row. ([[https://github.com/joonro/Get-ChildItemColor/issues/30][#30]])
** v3.0.0
Expand Down
4 changes: 2 additions & 2 deletions src/Get-ChildItemColor.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RootModule = 'Get-ChildItemColor.psm1'

# Version number of this module.
ModuleVersion = '3.1.0'
ModuleVersion = '3.2.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -69,7 +69,7 @@ Description = 'Get-ChildItemColor provides colored versions of Get-ChildItem Cmd
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Get-ChildItemColor',
'Get-ChildItemColorFormatWide'
'Get-ChildItemColorFormatWide',
'Out-ChildItemColor'
)

Expand Down
103 changes: 92 additions & 11 deletions src/Get-ChildItemColor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,104 @@ Function Out-ChildItemColor {
}

Function Get-ChildItemColor {
[CmdletBinding()]
Param(
[string]$Path = ""
)
[CmdletBinding(DefaultParameterSetName='Items', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096492')]
param(
[Parameter(ParameterSetName='Items', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string[]]
${Path},

[Parameter(ParameterSetName='LiteralItems', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
[Alias('PSPath','LP')]
[string[]]
${LiteralPath},

[Parameter(Position=1)]
[string]
${Filter},

[string[]]
${Include},

[string[]]
${Exclude},

[Alias('s')]
[switch]
${Recurse},

[uint]
${Depth},

[switch]
${Force},

[switch]
${Name})


dynamicparam
{
try {
$targetCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\Get-ChildItem', [System.Management.Automation.CommandTypes]::Cmdlet, $PSBoundParameters)
$dynamicParams = @($targetCmd.Parameters.GetEnumerator() | Microsoft.PowerShell.Core\Where-Object { $_.Value.IsDynamic })
if ($dynamicParams.Length -gt 0)
{
$paramDictionary = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
foreach ($param in $dynamicParams)
{
$param = $param.Value

if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name))
{
$dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes)
$paramDictionary.Add($param.Name, $dynParam)
}
}

Begin {
$Expression = "Get-ChildItem -Path `"$Path`" $Args"
$Items = Invoke-Expression $Expression
return $paramDictionary
}
} catch {
throw
}
}

begin
{
try {
$outBuffer = $null
if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
{
$PSBoundParameters['OutBuffer'] = 1
}

$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\Get-ChildItem', [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = {& $wrappedCmd @PSBoundParameters }

} catch {
throw
}
}

process
{
try {
$items = $scriptCmd.invoke()

Process {
If ($PSCmdlet.MyInvocation.Line -Match '\|') { # pipeline is used
$Items
$items
} Else {
$Items | Out-ChildItemColor
$items | Out-ChildItemColor
}
} catch {
throw
}
}

Export-ModuleMember -Function Out-ChildItemColor, 'Get-*'
end
{
try {
} catch {
throw
}
}
}

0 comments on commit 97d4a2f

Please sign in to comment.