From 56193740b20dcd23922457a4118b13a777ce9e4e Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sat, 25 Oct 2025 00:21:01 +0200 Subject: [PATCH 1/4] adds more metadata --- quickpath.psd1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quickpath.psd1 b/quickpath.psd1 index 31c8b80..e14ba28 100644 --- a/quickpath.psd1 +++ b/quickpath.psd1 @@ -12,7 +12,7 @@ RootModule = 'quickpath.psm1' # Version number of this module. - ModuleVersion = '0.14.3' + ModuleVersion = '0.14.3' # ID used to uniquely identify this module GUID = '376719b2-2cdd-47e8-b82b-b01870c08ac8' @@ -31,7 +31,7 @@ and even makes it easy to open the folders/projects in your favorite tools." # Minimum version of the PowerShell engine required by this module - # PowerShellVersion = '' + PowerShellVersion = '7.0' # Name of the PowerShell host required by this module # PowerShellHostName = '' @@ -93,7 +93,7 @@ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() + Tags = @('Navigation', 'CLI', 'Productivity', 'FileSystem') # A URL to the license for this module. # LicenseUri = '' From ce1455443e60e99c52abba9cadb4943924820a76 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sat, 25 Oct 2025 00:21:21 +0200 Subject: [PATCH 2/4] removes duplicate assignment --- quickpath.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickpath.psm1 b/quickpath.psm1 index 4a9429f..c67d466 100644 --- a/quickpath.psm1 +++ b/quickpath.psm1 @@ -45,7 +45,7 @@ $commandText function qp { try { $firstArgument = $args[0] - $remainingArguments = $remainingArguments = $args[1..($args.length - 1)] + $remainingArguments = $args[1..($args.length - 1)] $script:JSON_FILE_PATH = Get-Script-Path $commands = Get-Commands From b13c677a530dab581dd6b4df586b41785b41912b Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sat, 25 Oct 2025 00:21:56 +0200 Subject: [PATCH 3/4] adds command cache --- private/Get-Commands.ps1 | 61 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/private/Get-Commands.ps1 b/private/Get-Commands.ps1 index 3a8992f..4635fb1 100644 --- a/private/Get-Commands.ps1 +++ b/private/Get-Commands.ps1 @@ -1,35 +1,40 @@ . $PSScriptRoot\..\classes\Command.ps1 +$script:CachedCommands = $null + function Get-Commands { - return @( - [Command]::new("cd", "Set-Alias-Location") - [Command]::new("rider", "Open-Command rider" ) - [Command]::new("vs", "Open-Command visualstudio" ) - [Command]::new("visualstudio", "Open-Command visualstudio" ) - [Command]::new("intellij", "Open-Command intellij") - [Command]::new("code", "Open-Command code") - [Command]::new("ws", "Open-Command webstorm") - [Command]::new("webstorm", "Open-Command webstorm") - [Command]::new("explorer", "Open-Command explorer") - [Command]::new("sourcefolder", "Set-Source-Folder") - [Command]::new("help", 'Write-Host $(Get-DynamicHelp $commandNames)' ) - [Command]::new("alias", @( - [Command]::new("add", "Add-Alias" ), - [Command]::new("remove", "Remove-Alias" ) - [Command]::new("list", { Write-Host ($script:ALIASES | Format-Table | Out-String) }) - ) + if ($null -eq $script:CachedCommands) { + $script:CachedCommands = @( + [Command]::new("cd", "Set-Alias-Location") + [Command]::new("rider", "Open-Command rider" ) + [Command]::new("vs", "Open-Command visualstudio" ) + [Command]::new("visualstudio", "Open-Command visualstudio" ) + [Command]::new("intellij", "Open-Command intellij") + [Command]::new("code", "Open-Command code") + [Command]::new("ws", "Open-Command webstorm") + [Command]::new("webstorm", "Open-Command webstorm") + [Command]::new("explorer", "Open-Command explorer") + [Command]::new("sourcefolder", "Set-Source-Folder") + [Command]::new("help", 'Write-Host $(Get-DynamicHelp $commandNames)' ) + [Command]::new("alias", @( + [Command]::new("add", "Add-Alias" ), + [Command]::new("remove", "Remove-Alias" ) + [Command]::new("list", { Write-Host ($script:ALIASES | Format-Table | Out-String) }) ) - [Command]::new("todo", @( - [Command]::new("add", "Add-Todo") - [Command]::new("remove", { Write-Host "TODO: remove item from todolist: qp todo remove x" }) - [Command]::new("list", { Write-Host "TODO: Output todo list" }) - ) + ) + [Command]::new("todo", @( + [Command]::new("add", "Add-Todo") + [Command]::new("remove", { Write-Host "TODO: remove item from todolist: qp todo remove x" }) + [Command]::new("list", { Write-Host "TODO: Output todo list" }) ) - [Command]::new("version", { Write-Host (Get-MyModuleVersion) }) - [Command]::new("update", { - Write-Host "updating quickpath..." - Update-Module quickpath - Write-Host "quickpath has been updated" - }) + ) + [Command]::new("version", { Write-Host (Get-MyModuleVersion) }) + [Command]::new("update", { + Write-Host "updating quickpath..." + Update-Module quickpath + Write-Host "quickpath has been updated" + }) ) + } + return $script:CachedCommands } \ No newline at end of file From 569c1ff4b0ee55830aa74dce100082d775f17588 Mon Sep 17 00:00:00 2001 From: Mark Visschers Date: Sat, 25 Oct 2025 00:22:22 +0200 Subject: [PATCH 4/4] adds arraylist for aliases and some validation --- private/Alias-Helper.ps1 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/private/Alias-Helper.ps1 b/private/Alias-Helper.ps1 index 61bd801..c5552fb 100644 --- a/private/Alias-Helper.ps1 +++ b/private/Alias-Helper.ps1 @@ -64,16 +64,29 @@ function Resolve-FullPath([string]$path) { return [System.IO.Path]::GetFullPath((Join-Path $base $path)) } -function Add-Alias([string]$argument1, [string]$argument2) { +function Add-Alias { + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$argument1, + [string]$argument2 + ) + + Write-Verbose "Adding alias with argument1: $argument1, argument2: $argument2" + if (-not [string]::IsNullOrEmpty($argument2) ) { + Write-Verbose "Adding alias: $argument1 from path: $argument2" Add-AliasFromPath -alias $argument1 -path $argument2 } else { + Write-Verbose "Adding alias from JSON" Add-AliasFromJson($argument1) } $json = [AliasPathMapping]::ToJson($script:ALIASES) $json | Out-File $script:JSON_FILE_PATH + Write-Verbose "Alias added successfully." } function Add-AliasFromPath([string]$alias, [string]$path) { @@ -84,8 +97,6 @@ function Add-AliasFromPath([string]$alias, [string]$path) { return $script:ALIASES } - $script:ALIASES = @($script:ALIASES) - $newAliasPath = [AliasPathMapping]::new() $newAliasPath.Aliases = @($alias) $newAliasPath.WindowsPath = $resolvedPath @@ -107,7 +118,6 @@ function Add-AliasFromPath([string]$alias, [string]$path) { } function Add-AliasFromJson([string]$jsonString) { - $script:ALIASES = @($script:ALIASES) $newAliasPath = [AliasPathMapping]::FromJson($jsonString) if (!($newAliasPath)) { @@ -137,8 +147,6 @@ function Add-AliasFromJson([string]$jsonString) { } function Remove-Alias([string] $alias) { - $script:ALIASES = @($script:ALIASES) - # If alias isn't present anywhere, do nothing if (-not ($script:ALIASES | Where-Object { $_.Aliases -contains $alias })) { return $script:ALIASES