Skip to content

Commit 90ae80e

Browse files
authored
Merge pull request #191 from rulasg/control-inversion-in-user-order
feat(Use-Order): Control inversion on calling Show-ProjectItem
2 parents 580320e + fd689ee commit 90ae80e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

public/items/project_item_show.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,14 @@ function ShowAttribLine{
320320

321321
$AttributesToShow | ForEach-Object {
322322
$name = $_.Name
323+
$value = $_.Value
323324
$color = $_.Color
324325
$prefix = $_.Prefix
325326
$BetweenQuotes = $_.BetweenQuotes
326327
$DefaultValue = $_.DefaultValue ?? "[$name]"
327328
$HideIfEmpty = $_.HideIfEmpty
328329

329-
$value = $item.$name
330+
$value = $value ?? $item.$name
330331

331332
if($HideIfEmpty -and [string]::IsNullOrEmpty($value)){
332333
return

public/items/use_order.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function Use-Order {
77
[Parameter()][Alias("e")][switch]$OpenInEditor,
88
[Parameter()][Alias("w")][switch]$OpenInBrowser,
99
[Parameter()][Alias("p")][switch]$PassThru,
10-
[Parameter()][Alias("c")][switch]$ClearScreen
10+
[Parameter()][Alias("c")][switch]$ClearScreen,
11+
[Parameter()][scriptblock]$ShowProjectItemScriptBlock
1112
)
1213

1314
begin {
@@ -54,8 +55,17 @@ function Use-Order {
5455
return [PsCustomObject]$i
5556
}
5657

58+
# Get function to show item
59+
$ShowProjectItemScriptBlock = $ShowProjectItemScriptBlock ?? { param($parameters) Show-ProjectItem @parameters }
60+
5761
# Show item in console or editor
58-
Show-ProjectItem -Item $itemId -OpenInEditor:$OpenInEditor -OpenInBrowser:$OpenInBrowser -ClearScreen:$ClearScreen
62+
$params = @{
63+
Item = $itemId
64+
OpenInEditor = $OpenInEditor
65+
OpenInBrowser = $OpenInBrowser
66+
ClearScreen = $ClearScreen
67+
}
68+
$ShowProjectItemScriptBlock.Invoke($params)
5969
return
6070

6171
}

0 commit comments

Comments
 (0)