diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e23584..250e448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.3.1] 2025-05-30 + +### Added + +- Add VIM (i.e. `hjkl`) navigation support. + +### Fixed + +- Add parameter validation and mandatory to ensure commands don't fail + unexpectedly. + ## [0.3.0] 2025-05-29 ### Added diff --git a/PesterExplorer/PesterExplorer.psd1 b/PesterExplorer/PesterExplorer.psd1 index 59e550a..0e03106 100644 --- a/PesterExplorer/PesterExplorer.psd1 +++ b/PesterExplorer/PesterExplorer.psd1 @@ -12,7 +12,7 @@ RootModule = 'PesterExplorer.psm1' # Version number of this module. - ModuleVersion = '0.3.0' + ModuleVersion = '0.3.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PesterExplorer/Private/Get-ShortcutKeyPanel.ps1 b/PesterExplorer/Private/Get-ShortcutKeyPanel.ps1 index 24942e9..a462244 100644 --- a/PesterExplorer/Private/Get-ShortcutKeyPanel.ps1 +++ b/PesterExplorer/Private/Get-ShortcutKeyPanel.ps1 @@ -20,11 +20,11 @@ function Get-ShortcutKeyPanel { #> [CmdletBinding()] $shortcutKeys = @( - "Up, Down - Navigate", + "Up/J, Down/K - Navigate", "Home, End - Jump to Top/Bottom", "PageUp, PageDown - Scroll", - "Enter - Explore", - "Tab - Switch Panel", + "Enter - Explore Item", + "Tab, Left/H, Right/L - Switch Panel", "Esc - Back", "Ctrl+C - Exit" ) diff --git a/PesterExplorer/Public/Show-PesterResult.ps1 b/PesterExplorer/Public/Show-PesterResult.ps1 index 36f6244..759e19c 100644 --- a/PesterExplorer/Public/Show-PesterResult.ps1 +++ b/PesterExplorer/Public/Show-PesterResult.ps1 @@ -27,6 +27,7 @@ function Show-PesterResult { Justification='This is actually used in the script block.' )] param ( + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [Pester.Run] $PesterResult, @@ -89,14 +90,13 @@ function Show-PesterResult { # Handle input $lastKeyPressed = Get-LastKeyPressed - # ToDo: Add vim navigation keys if ($null -ne $lastKeyPressed) { #region List Navigation if($selectedPane -eq 'list') { - if ($lastKeyPressed.Key -eq "DownArrow") { + if ($lastKeyPressed.Key -in @("j", "DownArrow")) { $selectedItem = $list[($list.IndexOf($selectedItem) + 1) % $list.Count] $scrollPosition = 0 - } elseif ($lastKeyPressed.Key -eq "UpArrow") { + } elseif ($lastKeyPressed.Key -in @("k", "UpArrow")) { $selectedItem = $list[($list.IndexOf($selectedItem) - 1 + $list.Count) % $list.Count] $scrollPosition = 0 } elseif ($lastKeyPressed.Key -eq "PageDown") { @@ -115,7 +115,7 @@ function Show-PesterResult { } elseif ($lastKeyPressed.Key -eq "End") { $selectedItem = $list[-1] $scrollPosition = 0 - } elseif ($lastKeyPressed.Key -in @("Tab", "RightArrow")) { + } elseif ($lastKeyPressed.Key -in @("Tab", "RightArrow", "l")) { $selectedPane = 'preview' } elseif ($lastKeyPressed.Key -eq "Enter") { <# Recurse into Pester Object #> @@ -150,8 +150,7 @@ function Show-PesterResult { } else { #region Preview Navigation - # ToDo: Add support for scrolling the right panel - if ($lastKeyPressed.Key -in "Escape", "Tab", "LeftArrow", "RightArrow") { + if ($lastKeyPressed.Key -in "Escape", "Tab", "LeftArrow", "h") { $selectedPane = 'list' } elseif ($lastKeyPressed.Key -eq "Down") { # Scroll down in the preview panel @@ -172,8 +171,22 @@ function Show-PesterResult { # Generate new data $titlePanel = Get-TitlePanel -Item $object - $listPanel = Get-ListPanel -List $list -SelectedItem $selectedItem -SelectedPane $selectedPane - $previewPanel = Get-PreviewPanel -Items $items -SelectedItem $selectedItem -ScrollPosition $scrollPosition -PreviewHeight $previewHeight -PreviewWidth $previewWidth -SelectedPane $selectedPane + $getListPanelSplat = @{ + List = $list + SelectedItem = $selectedItem + SelectedPane = $selectedPane + } + $listPanel = Get-ListPanel @getListPanelSplat + + $getPreviewPanelSplat = @{ + Items = $items + SelectedItem = $selectedItem + ScrollPosition = $scrollPosition + PreviewHeight = $previewHeight + PreviewWidth = $previewWidth + SelectedPane = $selectedPane + } + $previewPanel = Get-PreviewPanel @getPreviewPanelSplat # Update layout $layout["header"].Update($titlePanel) | Out-Null diff --git a/PesterExplorer/Public/Show-PesterResultTree.ps1 b/PesterExplorer/Public/Show-PesterResultTree.ps1 index 57657d5..8feda02 100644 --- a/PesterExplorer/Public/Show-PesterResultTree.ps1 +++ b/PesterExplorer/Public/Show-PesterResultTree.ps1 @@ -20,6 +20,8 @@ function Show-PesterResultTree { [CmdletBinding()] [OutputType([void])] param ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] [Pester.Run] $PesterResult ) diff --git a/docs/en-US/Show-PesterResult.md b/docs/en-US/Show-PesterResult.md index 02aab3a..fc9fc82 100644 --- a/docs/en-US/Show-PesterResult.md +++ b/docs/en-US/Show-PesterResult.md @@ -13,7 +13,7 @@ Open a TUI to explore the Pester result object. ## SYNTAX ``` -Show-PesterResult [[-PesterResult] ] [-NoShortcutPanel] [-ProgressAction ] +Show-PesterResult [-PesterResult] [-NoShortcutPanel] [-ProgressAction ] [] ``` @@ -42,7 +42,7 @@ Type: Run Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 1 Default value: None Accept pipeline input: False diff --git a/docs/en-US/Show-PesterResultTree.md b/docs/en-US/Show-PesterResultTree.md index cbf270f..4060296 100644 --- a/docs/en-US/Show-PesterResultTree.md +++ b/docs/en-US/Show-PesterResultTree.md @@ -13,7 +13,7 @@ Show a Pester result in a tree format using Spectre.Console. ## SYNTAX ``` -Show-PesterResultTree [[-PesterResult] ] [-ProgressAction ] [] +Show-PesterResultTree [-PesterResult] [-ProgressAction ] [] ``` ## DESCRIPTION @@ -43,7 +43,7 @@ Type: Run Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 1 Default value: None Accept pipeline input: False