Skip to content

Commit 97d4a2f

Browse files
committed
Merge branch 'release/v3.2.0'
2 parents 19142e4 + ddbb5b4 commit 97d4a2f

File tree

3 files changed

+97
-13
lines changed

3 files changed

+97
-13
lines changed

README.org

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ $Global:GetChildItemColorVerticalSpace = 1
111111
* Authors
112112
- [[http://github.com/joonro][Joon Ro]].
113113
* Changelog
114+
** v3.2.0
115+
- Make ~Get-ChildItemColor~ a proxy function of ~~Get-ChildItem~, so
116+
~Get-ChildItemColor~ supports all the parameters of the original function.
114117
** v3.1.0
115118
- ~Get-ChildItemColor~ only highlights names instead of highlighting the whole row. ([[https://github.com/joonro/Get-ChildItemColor/issues/30][#30]])
116119
** v3.0.0

src/Get-ChildItemColor.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
RootModule = 'Get-ChildItemColor.psm1'
1111

1212
# Version number of this module.
13-
ModuleVersion = '3.1.0'
13+
ModuleVersion = '3.2.0'
1414

1515
# Supported PSEditions
1616
# CompatiblePSEditions = @()
@@ -69,7 +69,7 @@ Description = 'Get-ChildItemColor provides colored versions of Get-ChildItem Cmd
6969
# 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.
7070
FunctionsToExport = @(
7171
'Get-ChildItemColor',
72-
'Get-ChildItemColorFormatWide'
72+
'Get-ChildItemColorFormatWide',
7373
'Out-ChildItemColor'
7474
)
7575

src/Get-ChildItemColor.psm1

Lines changed: 92 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,23 +203,104 @@ Function Out-ChildItemColor {
203203
}
204204

205205
Function Get-ChildItemColor {
206-
[CmdletBinding()]
207-
Param(
208-
[string]$Path = ""
209-
)
206+
[CmdletBinding(DefaultParameterSetName='Items', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096492')]
207+
param(
208+
[Parameter(ParameterSetName='Items', Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
209+
[string[]]
210+
${Path},
211+
212+
[Parameter(ParameterSetName='LiteralItems', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
213+
[Alias('PSPath','LP')]
214+
[string[]]
215+
${LiteralPath},
216+
217+
[Parameter(Position=1)]
218+
[string]
219+
${Filter},
220+
221+
[string[]]
222+
${Include},
223+
224+
[string[]]
225+
${Exclude},
226+
227+
[Alias('s')]
228+
[switch]
229+
${Recurse},
230+
231+
[uint]
232+
${Depth},
233+
234+
[switch]
235+
${Force},
236+
237+
[switch]
238+
${Name})
239+
240+
241+
dynamicparam
242+
{
243+
try {
244+
$targetCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\Get-ChildItem', [System.Management.Automation.CommandTypes]::Cmdlet, $PSBoundParameters)
245+
$dynamicParams = @($targetCmd.Parameters.GetEnumerator() | Microsoft.PowerShell.Core\Where-Object { $_.Value.IsDynamic })
246+
if ($dynamicParams.Length -gt 0)
247+
{
248+
$paramDictionary = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
249+
foreach ($param in $dynamicParams)
250+
{
251+
$param = $param.Value
252+
253+
if(-not $MyInvocation.MyCommand.Parameters.ContainsKey($param.Name))
254+
{
255+
$dynParam = [Management.Automation.RuntimeDefinedParameter]::new($param.Name, $param.ParameterType, $param.Attributes)
256+
$paramDictionary.Add($param.Name, $dynParam)
257+
}
258+
}
210259

211-
Begin {
212-
$Expression = "Get-ChildItem -Path `"$Path`" $Args"
213-
$Items = Invoke-Expression $Expression
260+
return $paramDictionary
261+
}
262+
} catch {
263+
throw
214264
}
265+
}
266+
267+
begin
268+
{
269+
try {
270+
$outBuffer = $null
271+
if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
272+
{
273+
$PSBoundParameters['OutBuffer'] = 1
274+
}
275+
276+
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Microsoft.PowerShell.Management\Get-ChildItem', [System.Management.Automation.CommandTypes]::Cmdlet)
277+
$scriptCmd = {& $wrappedCmd @PSBoundParameters }
278+
279+
} catch {
280+
throw
281+
}
282+
}
283+
284+
process
285+
{
286+
try {
287+
$items = $scriptCmd.invoke()
215288

216-
Process {
217289
If ($PSCmdlet.MyInvocation.Line -Match '\|') { # pipeline is used
218-
$Items
290+
$items
219291
} Else {
220-
$Items | Out-ChildItemColor
292+
$items | Out-ChildItemColor
221293
}
294+
} catch {
295+
throw
222296
}
223297
}
224298

225-
Export-ModuleMember -Function Out-ChildItemColor, 'Get-*'
299+
end
300+
{
301+
try {
302+
} catch {
303+
throw
304+
}
305+
}
306+
}

0 commit comments

Comments
 (0)