From 851655be245d88003fe9934ba4136a70e5b18ca8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 26 Apr 2025 10:39:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20'ErrorView'=20i?= =?UTF-8?q?nput=20to=20configure=20PowerShell=20error=20display=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + action.yml | 5 +++++ scripts/init.ps1 | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index c24f3e3..b09f491 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ To get started with your own GitHub PowerShell based action, [create a new repos | `Verbose` | Enable verbose output. | false | `'false'` | | `Version` | Specifies the exact version of the GitHub module to install. | false | | | `Prerelease` | Allow prerelease versions if available. | false | `'false'` | +| `ErrorView` | Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials. | false | `'NormalView'` | | `ShowInfo` | Show information about the environment. | false | `'true'` | | `ShowInit` | Show information about the initialization. | false | `'false'` | | `ShowOutput` | Show the script's output. | false | `'false'` | diff --git a/action.yml b/action.yml index cf535b0..c77922a 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,10 @@ inputs: description: Show the output of the script. required: false default: 'false' + ErrorView: + description: Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials. + required: false + default: 'NormalView' WorkingDirectory: description: The working directory where the script will run from. required: false @@ -79,6 +83,7 @@ runs: PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo: ${{ inputs.ShowInfo }} PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput: ${{ inputs.ShowOutput }} PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }} + PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }} run: | # ${{ inputs.Name }} try { diff --git a/scripts/init.ps1 b/scripts/init.ps1 index ec889ea..486802c 100644 --- a/scripts/init.ps1 +++ b/scripts/init.ps1 @@ -5,6 +5,22 @@ begin { $scriptName = $MyInvocation.MyCommand.Name Write-Debug "[$scriptName] - Start" $PSStyle.OutputRendering = 'Ansi' + + # Configure ErrorView based on input parameter + if (-not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView)) { + $validViews = @('NormalView', 'CategoryView', 'ConciseView', 'DetailedView') + $errorViewSetting = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView + + # Simply find the first validView that matches the input using wildcards + $matchedView = $validViews | Where-Object { $_ -like "*$errorViewSetting*" } | Select-Object -First 1 + + if ($matchedView) { + Write-Debug "[$scriptName] - Input [$errorViewSetting] matched with [$matchedView]" + $ErrorView = $matchedView + } else { + Write-Warning "[$scriptName] - Invalid ErrorView value: [$errorViewSetting]. Using default." + } + } } process {