Skip to content

Commit 87a536c

Browse files
Merge pull request #69 from PowershellFrameworkCollective/Development
2.2.38
2 parents 4188226 + a2fc09d commit 87a536c

File tree

11 files changed

+306
-67
lines changed

11 files changed

+306
-67
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
FriedrichWeinmann
5+
patreon: # Replace with a single Patreon username
6+
open_collective: # Replace with a single Open Collective username
7+
ko_fi: # Replace with a single Ko-fi username
8+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
liberapay: # Replace with a single Liberapay username
11+
issuehunt: # Replace with a single IssueHunt username
12+
otechie: # Replace with a single Otechie username
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- main
6+
7+
jobs:
8+
build:
9+
10+
runs-on: windows-latest
11+
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Install Prerequisites
15+
run: .\build\psf-prerequisites.ps1 -Bootstrap
16+
shell: powershell
17+
- name: Validate
18+
run: .\build\vsts-validate.ps1
19+
shell: powershell
20+
- name: Build
21+
run: .\build\psf-build.ps1 -ApiKey $env:APIKEY
22+
shell: powershell
23+
env:
24+
APIKEY: ${{ secrets.ApiKey }}

.github/workflows/validate.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
validate:
5+
6+
runs-on: windows-latest
7+
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Install Prerequisites
11+
run: .\build\psf-prerequisites.ps1 -Bootstrap
12+
shell: powershell
13+
- name: Validate
14+
run: .\build\vsts-validate.ps1
15+
shell: powershell

PSUtil/PSUtil.psd1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
# Modules that must be imported into the global environment prior to importing
2828
# this module
2929
RequiredModules = @(
30-
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.6.205' }
31-
@{ ModuleName = 'string'; ModuleVersion = '1.0.0' }
30+
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.12.346' }
31+
@{ ModuleName = 'string'; ModuleVersion = '1.1.5' }
3232
)
3333

3434
# Assemblies that must be loaded prior to importing this module
@@ -55,6 +55,7 @@
5555
'Register-PSUObjectConversion'
5656
'Register-PSUObjectExpansion'
5757
'Read-PSUKnowledge'
58+
'Remove-PSUDirectory'
5859
'Remove-PSUKnowledge'
5960
'Remove-PSUPathAlias'
6061
'Select-PSUFunctionCode'
@@ -108,6 +109,7 @@
108109
'ocb'
109110
'ov'
110111
'page'
112+
'rcd'
111113
'rdk'
112114
'read'
113115
'Remove-PSUString'

PSUtil/changelog.md

Lines changed: 80 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,108 @@
11
# Changelog
22

3+
## 2.2.38 (2025-05-31)
4+
5+
+ New: Remove-PSUDirectory - Removes the current directory and moves the console to the parent folder.
6+
+ Upd: Prompt Fred - added nested prompt level if greater than 0
7+
+ Fix: Remove-PSUKnowledge - now actually works
8+
39
## 2.2.35 (2021-10-13)
410

5-
- New: Object Conversion - NT <--> SID
6-
- New: Object Conversion - string <--> base64
7-
- New: Command Get-PSUCalendarWeek - Calculates the calendar week of the specified date.
8-
- Upd: Start-PSUTimer - added `-RandomInterval` parameter, randomizing the sound playback interval
9-
- Upd: Start-PSUTimer - added `-DisableScreensaver` parameter, blocking screensaver for the duration of the timer
10-
- Upd: Start-PSUTimer - now automatically adds a day if the destination-time is in the past
11-
- Upd: Manifest - added ctx and cfx to the aliases exported, enabling auto-import from using those.
11+
+ New: Object Conversion - NT <--> SID
12+
+ New: Object Conversion - string <--> base64
13+
+ New: Command Get-PSUCalendarWeek - Calculates the calendar week of the specified date.
14+
+ Upd: Start-PSUTimer - added `-RandomInterval` parameter, randomizing the sound playback interval
15+
+ Upd: Start-PSUTimer - added `-DisableScreensaver` parameter, blocking screensaver for the duration of the timer
16+
+ Upd: Start-PSUTimer - now automatically adds a day if the destination-time is in the past
17+
+ Upd: Manifest - added ctx and cfx to the aliases exported, enabling auto-import from using those.
1218

1319
## 2.1.28 (2020-03-21)
14-
- New: Component: Knowledge - store and search knowledge
15-
- New: Command: Read-PSUKnowledge (read, page, learn) - retrieves stored knowledge
16-
- New: Command: Write-PSUKnowledge - writes knowledge for later retrieval
17-
- New: Command: Remove-PSUKnowledge - removes knowledge from storage. Use on alternative facts.
18-
- New: Command: Out-PSUVariable - writes input to variable, enabling variable assignment at the end of the pipeline
19-
- New: Alias rmn --> Remove-PSFNull
20-
- New: Dependency on string module, dropping own string cmdlets, ading aliases for compatibility
21-
- New: Adding psf tab completion for property names to common object commands
20+
21+
+ New: Component: Knowledge - store and search knowledge
22+
+ New: Command: Read-PSUKnowledge (read, page, learn) - retrieves stored knowledge
23+
+ New: Command: Write-PSUKnowledge - writes knowledge for later retrieval
24+
+ New: Command: Remove-PSUKnowledge - removes knowledge from storage. Use on alternative facts.
25+
+ New: Command: Out-PSUVariable - writes input to variable, enabling variable assignment at the end of the pipeline
26+
+ New: Alias rmn --> Remove-PSFNull
27+
+ New: Dependency on string module, dropping own string cmdlets, ading aliases for compatibility
28+
+ New: Adding psf tab completion for property names to common object commands
2229

2330
## 2.0.20 (2019-09-18)
24-
- New: Command: Set-PSUPrompt - Applies a prompt from a set of pre-defined prompts
25-
- New: Command: Register-PSUObjectExpansion - Registers custom expansion rules for Expand-PSUObject
26-
- Upd: Start-PSUTimer - Added -MinFrequency and -MaxFrequency parameters.
27-
- Upd: Start-PSUTimer - Refactored parameter order, rationalized message handling
28-
- Upd: Invoke-PSUExplorer - Enabled opt-in exceptions and improved path resolution
29-
- Upd: Set-PSUPath - Now supports environment variable expansion using %name% notation.
30-
- Fix: Importing module from UNC path works
31-
- Fix: Module import concurrency issue
32-
- Fix: Convert-PSUObject unsafe Scriptblock handling
33-
- Fix: Set-PSUShell foreground color handling (requires latest pre-release version of PSReadline)
34-
- Fix: F1 Keybinding: On non-windows default to detailed help, rather than -ShowWindow
35-
- Fix: F1 Keybinding: In-Console help display now uses same application as launching application
31+
32+
+ New: Command: Set-PSUPrompt - Applies a prompt from a set of pre-defined prompts
33+
+ New: Command: Register-PSUObjectExpansion - Registers custom expansion rules for Expand-PSUObject
34+
+ Upd: Start-PSUTimer - Added -MinFrequency and -MaxFrequency parameters.
35+
+ Upd: Start-PSUTimer - Refactored parameter order, rationalized message handling
36+
+ Upd: Invoke-PSUExplorer - Enabled opt-in exceptions and improved path resolution
37+
+ Upd: Set-PSUPath - Now supports environment variable expansion using %name% notation.
38+
+ Fix: Importing module from UNC path works
39+
+ Fix: Module import concurrency issue
40+
+ Fix: Convert-PSUObject unsafe Scriptblock handling
41+
+ Fix: Set-PSUShell foreground color handling (requires latest pre-release version of PSReadline)
42+
+ Fix: F1 Keybinding: On non-windows default to detailed help, rather than -ShowWindow
43+
+ Fix: F1 Keybinding: In-Console help display now uses same application as launching application
3644

3745
## Version 2.0.8 (2019-01-13)
38-
- New: Keybinding for `Shift+SpaceBar` on PSReadline 2.0 that inserts a whitespace, helping to mitigate the typing issue in the windows release version.
39-
- Upd: Switched input property tab completion to PSFramework implementation: PSFramework-Input-ObjectProperty
40-
- Upd: Default keybinding for expanding aliases was changed to `Alt` + `q`. The previous one was inoperable under PSReadline 2.0 or later.
41-
- Fix: Get-PSUPathAlias returns empty objects (thanks Corbob)
46+
47+
+ New: Keybinding for `Shift+SpaceBar` on PSReadline 2.0 that inserts a whitespace, helping to mitigate the typing issue in the windows release version.
48+
+ Upd: Switched input property tab completion to PSFramework implementation: PSFramework-Input-ObjectProperty
49+
+ Upd: Default keybinding for expanding aliases was changed to `Alt` + `q`. The previous one was inoperable under PSReadline 2.0 or later.
50+
+ Fix: Get-PSUPathAlias returns empty objects (thanks Corbob)
4251

4352
## Version 2.0.4 (2018-12-23)
44-
- Fix: Persisting default aliases redirection fails
53+
54+
+ Fix: Persisting default aliases redirection fails
4555

4656
## Version 2.0.3 (2018-12-23)
47-
- New: Configuration setting 'PSUtil.Import.Alias.SystemOverride'. Persisting this will have PSUtil replace system default aliases.
48-
- New: Tab Expansion for PowerShellGet
49-
- New: Tab Expansion for Select-Object and Select-PSFObject
57+
58+
+ New: Configuration setting 'PSUtil.Import.Alias.SystemOverride'. Persisting this will have PSUtil replace system default aliases.
59+
+ New: Tab Expansion for PowerShellGet
60+
+ New: Tab Expansion for Select-Object and Select-PSFObject
5061

5162
## Version 2.0.0 (2018-12-15)
52-
- new: Command Get-PSUPathAlias lists all current path aliases
53-
- new: Command Remove-PSUPathAlias removes a path alias
54-
- new: Command Set-PSUPath used to implement the path alias functionality
55-
- new: Command Set-PSUPathAlias creates or updates an alias for a path
56-
- other: Major project refactoring
57-
- rem: Command `Select-PSUObject` has been removed
58-
- new: Alias `Select-PSUObject` pointing at `Select-PSFPobject`
59-
- upd: Alias `ex` now points at `Export-PSFClixml`
60-
- upd: Alias `ix` now points at `Import-PSFClixml`
61-
- upd: Alias `spo` now points at `Select-PSFObject`
62-
- upd: Moved the list of default properties to expand using Expand-PSUObject to configuration
63+
64+
+ new: Command Get-PSUPathAlias lists all current path aliases
65+
+ new: Command Remove-PSUPathAlias removes a path alias
66+
+ new: Command Set-PSUPath used to implement the path alias functionality
67+
+ new: Command Set-PSUPathAlias creates or updates an alias for a path
68+
+ other: Major project refactoring
69+
+ rem: Command `Select-PSUObject` has been removed
70+
+ new: Alias `Select-PSUObject` pointing at `Select-PSFPobject`
71+
+ upd: Alias `ex` now points at `Export-PSFClixml`
72+
+ upd: Alias `ix` now points at `Import-PSFClixml`
73+
+ upd: Alias `spo` now points at `Select-PSFObject`
74+
+ upd: Moved the list of default properties to expand using Expand-PSUObject to configuration
6375

6476
## Version 1.1.5.17 (2018-06-19)
65-
- new: Command Select-PSUObject - Select-Object in awesome.
66-
- upd: Command Set-PSUString / replace - can now do lambda replacement
77+
78+
+ new: Command Select-PSUObject - Select-Object in awesome.
79+
+ upd: Command Set-PSUString / replace - can now do lambda replacement
6780

6881
## Version 1.1.4.15 (2018-03-30)
69-
- new: Select-PSUFunctionCode / Inspect
82+
83+
+ new: Select-PSUFunctionCode / Inspect
7084

7185
## Version 1.1.3.13 (2018-03-20)
72-
- new: Command Start-PSUTimer / timer
86+
87+
+ new: Command Start-PSUTimer / timer
7388

7489
## Version 1.1.2.12 (2018-03-06)
75-
- new: Command Backup-PSULocation / bu (#18)
76-
- new: Command Set-PSUDrive / set-as (#18)
77-
- new: Command New-PSUDirectory / mcd (#18)
90+
91+
+ new: Command Backup-PSULocation / bu (#18)
92+
+ new: Command Set-PSUDrive / set-as (#18)
93+
+ new: Command New-PSUDirectory / mcd (#18)
7894

7995
## Version 1.1.1.10 (2018-02-23)
80-
- upd: Select-PSUObjectSample / s can now select last items (#15)
81-
- fix: Format-PSUString / format will now format numbers correctly (#14)
96+
97+
+ upd: Select-PSUObjectSample / s can now select last items (#15)
98+
+ fix: Format-PSUString / format will now format numbers correctly (#14)
8299

83100
## Version 1.1.1.9 (2018-02-02)
84-
- new: Command Convert-PSUObject / convert. (#9)
85-
Allows converting input from a source format to a destination format. Can be dynamically extended.
86-
- new: Command Register-PSUObjectConversion. (#9)
87-
Registers conversion path for Convert-PSUObject.
88-
- new: Added module tests and build definition for CI/CD integration
89-
- upd: All keybindings can now be configured using the config system. Changes require reimport to apply. (#7)
90-
- fix: Fixed 'replace' not accepting empty string as replace with option (#8)
101+
102+
+ new: Command Convert-PSUObject / convert. (#9)
103+
Allows converting input from a source format to a destination format. Can be dynamically extended.
104+
+ new: Command Register-PSUObjectConversion. (#9)
105+
Registers conversion path for Convert-PSUObject.
106+
+ new: Added module tests and build definition for CI/CD integration
107+
+ upd: All keybindings can now be configured using the config system. Changes require reimport to apply. (#7)
108+
+ fix: Fixed 'replace' not accepting empty string as replace with option (#8)

PSUtil/en-us/strings.psd1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@{
2+
'Remove-PSUDirectory.Error.IsRootPath' = 'This is the drive root, not deleting the entire volume for you! {0}' # location
3+
'Remove-PSUDirectory.Error.NotFileSystem' = 'Not a filesystem path, cannot remove the current location: {0}' # $location
4+
'Remove-PSUDirectory.RemoveItem' = 'Removing {0} items in {1}' # $children.Count, $location
25
'Set-PSUKnowledge.Library.Path.CreationFailed' = 'Failed to create library path: {0}. Validate the path and ensure the necessary permissions are in place.' # $libraryPath
3-
'Set-PSUKnowledge.Book.ImportFailed' = 'Failed to read the book "{0}" from "{1}"' # $Book, $bookPath
4-
'Set-PSUKnowledge.Book.ExportFailed' = 'Failed to write the page "{0}" into the book "{1}" at "{2}"' # $Name, $Book, $bookPath
6+
'Set-PSUKnowledge.Book.ImportFailed' = 'Failed to read the book "{0}" from "{1}"' # $Book, $bookPath
7+
'Set-PSUKnowledge.Book.ExportFailed' = 'Failed to write the page "{0}" into the book "{1}" at "{2}"' # $Name, $Book, $bookPath
58
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
function Remove-PSUDirectory {
2+
<#
3+
.SYNOPSIS
4+
Removes the current directory and moves the console to the parent folder.
5+
6+
.DESCRIPTION
7+
Removes the current directory and moves the console to the parent folder.
8+
9+
.PARAMETER Force
10+
Don't ask questions, just do it.
11+
12+
.PARAMETER EnableException
13+
This parameters disables user-friendly warnings and enables the throwing of exceptions.
14+
This is less user friendly, but allows catching exceptions in calling scripts.
15+
16+
.PARAMETER WhatIf
17+
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
18+
19+
.PARAMETER Confirm
20+
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
21+
22+
.EXAMPLE
23+
PS C:\> rcd
24+
25+
Tries to remove the directory and step back one level.
26+
#>
27+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
28+
param (
29+
[switch]
30+
$Force,
31+
32+
[switch]
33+
$EnableException
34+
)
35+
process {
36+
$location = Get-Location
37+
if ($location.Provider.Name -ne 'FileSystem') {
38+
Stop-PSFFunction -String 'Remove-PSUDirectory.Error.NotFileSystem' -StringValues $location -EnableException $EnableException -Cmdlet $PSCmdlet
39+
return
40+
}
41+
42+
if ($location.Path -eq "$($location.Drive):\") {
43+
Stop-PSFFunction -String 'Remove-PSUDirectory.Error.IsRootPath' -StringValues $location -EnableException $EnableException -Cmdlet $PSCmdlet
44+
return
45+
}
46+
47+
$children = Get-ChildItem -LiteralPath $location -Force -Recurse
48+
if ($children.Count -lt 1) {
49+
Set-Location -Path '..'
50+
Remove-Item -LiteralPath $location -Force -Confirm:$false
51+
return
52+
}
53+
54+
if ($Force -or (Test-PSFShouldProcess -Target $location -ActionString 'PSUtil.Remove-PSUDirectory.RemoveItem' -ActionStringValues $children.Count, $location -PSCmdlet $PSCmdlet)) {
55+
Set-Location -Path '..'
56+
Remove-Item -LiteralPath $location -Force -Confirm:$false
57+
}
58+
}
59+
}
60+
61+
Import-PSUAlias -Name "rcd" -Command "Remove-PSUDirectory"

PSUtil/functions/knowledge/Remove-PSUKnowledge.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{
4343
if (-not (Test-Path -Path $libraryPath)) { return }
4444

45-
$bookName = '{0}.json' -f [System.Text.Encoding]::UTF8.GetBytes($Book)
45+
$bookName = '{0}.json' -f [System.Convert]::ToBase64String(([System.Text.Encoding]::UTF8.GetBytes($Book)))
4646
$bookPath = Join-Path $libraryPath $bookName
4747

4848
if (-not (Test-Path -Path $bookPath)) { return }

PSUtil/internal/prompts/fred.prompt.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
}
1010
}
1111
catch { }
12+
if ($NestedPromptLevel -gt 0) {
13+
Write-PSFHostColor -String "[<c='sub'>$NestedPromptLevel</c>] " -NoNewLine -DefaultColor DarkGreen
14+
}
1215
$segments = $executionContext.SessionState.Path.CurrentLocation.Path -split "\\"
1316
if ($segments.Count -lt 4) { Write-Host "$($executionContext.SessionState.Path.CurrentLocation.Path)" -NoNewline }
1417
else { Write-Host "($($segments.Count - 2)) ..\$($segments[-2])\$($segments[-1])" -NoNewline }

0 commit comments

Comments
 (0)