Skip to content

Commit 851655b

Browse files
🩹 [Patch]: Add 'ErrorView' input to configure PowerShell error display settings
1 parent 23bc6b9 commit 851655b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ To get started with your own GitHub PowerShell based action, [create a new repos
1919
| `Verbose` | Enable verbose output. | false | `'false'` |
2020
| `Version` | Specifies the exact version of the GitHub module to install. | false | |
2121
| `Prerelease` | Allow prerelease versions if available. | false | `'false'` |
22+
| `ErrorView` | Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials. | false | `'NormalView'` |
2223
| `ShowInfo` | Show information about the environment. | false | `'true'` |
2324
| `ShowInit` | Show information about the initialization. | false | `'false'` |
2425
| `ShowOutput` | Show the script's output. | false | `'false'` |

‎action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ inputs:
5050
description: Show the output of the script.
5151
required: false
5252
default: 'false'
53+
ErrorView:
54+
description: Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials.
55+
required: false
56+
default: 'NormalView'
5357
WorkingDirectory:
5458
description: The working directory where the script will run from.
5559
required: false
@@ -79,6 +83,7 @@ runs:
7983
PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo: ${{ inputs.ShowInfo }}
8084
PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput: ${{ inputs.ShowOutput }}
8185
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
86+
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
8287
run: |
8388
# ${{ inputs.Name }}
8489
try {

‎scripts/init.ps1‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ begin {
55
$scriptName = $MyInvocation.MyCommand.Name
66
Write-Debug "[$scriptName] - Start"
77
$PSStyle.OutputRendering = 'Ansi'
8+
9+
# Configure ErrorView based on input parameter
10+
if (-not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView)) {
11+
$validViews = @('NormalView', 'CategoryView', 'ConciseView', 'DetailedView')
12+
$errorViewSetting = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
13+
14+
# Simply find the first validView that matches the input using wildcards
15+
$matchedView = $validViews | Where-Object { $_ -like "*$errorViewSetting*" } | Select-Object -First 1
16+
17+
if ($matchedView) {
18+
Write-Debug "[$scriptName] - Input [$errorViewSetting] matched with [$matchedView]"
19+
$ErrorView = $matchedView
20+
} else {
21+
Write-Warning "[$scriptName] - Invalid ErrorView value: [$errorViewSetting]. Using default."
22+
}
23+
}
824
}
925

1026
process {

0 commit comments

Comments
 (0)