Skip to content

Commit bb5f0e6

Browse files
committed
📝 [docs] Overhaul and enhance cmdlet documentation
This commit introduces a comprehensive overhaul of the external help documentation (Markdown and XML files) for all major cmdlets, alongside several code refinements and feature enhancements. ### Documentation (`📝 [docs]`) - **Complete Rewrite**: The help content for `Add-ColorScriptProfile`, `Build-ColorScriptCache`, `Clear-ColorScriptCache`, and other cmdlets has been completely rewritten for clarity, accuracy, and detail. - **Richer Examples**: Adds more diverse and practical examples for each cmdlet, including pipeline usage and combinations of parameters. - **Improved Descriptions**: Parameter descriptions, notes, and cmdlet summaries are expanded to better explain the "why" behind features, their behavior, and best practices. - **Standardization**: Ensures consistent formatting, structure, and tone across all help files, including updating the MAML XML to reflect the Markdown changes. ### Refactoring & Fixes (`🚜 [refactor]`) - **Lazy Initialization**: The cache directory is no longer initialized on module import. Instead, it's created lazily on the first call to a function that requires it, improving module load times. - **Code Simplification**: - Refactors `Save-ColorScriptConfiguration` to remove a redundant variable, simplifying the logic for checking existing configuration content. - Fixes a potential divide-by-zero error in `Build-ColorScriptCache`'s progress calculation when processing an empty set of scripts. ### Build & Metadata (`🔧 [build]`) - **Build Output**: Modifies `.gitignore` to explicitly include the `dist` directory, ensuring it's available for packaging and distribution workflows. - **Version Bump**: Increments the module version and updates the description to reflect the new total count of 498 colorscripts. Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>
1 parent d60c0a6 commit bb5f0e6

23 files changed

Lines changed: 4215 additions & 1673 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,4 @@ coverage-report/
349349
testResults.xml
350350
test-results.xml
351351
*.coverage
352+
!dist

ColorScripts-Enhanced/ColorScripts-Enhanced.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'ColorScripts-Enhanced.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '2025.10.26.1521'
14+
ModuleVersion = '2025.10.26.1957'
1515

1616
# Supported PSEditions
1717
CompatiblePSEditions = @('Desktop', 'Core')
@@ -33,7 +33,7 @@
3333
Enhanced PowerShell ColorScripts with high-performance caching system. Display beautiful ANSI art in your terminal with 6-19x faster load times.
3434
3535
Features:
36-
245+ beautiful colorscripts - Extensive collection of ANSI art
36+
498 beautiful colorscripts - Extensive collection of ANSI art
3737
• Intelligent Caching - 6-19x performance improvement (5-20ms load times)
3838
• OS-Wide Cache - Consistent caching across all terminal sessions
3939
• Simple API - Easy-to-use cmdlets with tab completion
@@ -172,7 +172,7 @@ Full documentation: https://github.com/Nick2bad4u/ps-color-scripts-enhanced
172172

173173
# ReleaseNotes of this module
174174
ReleaseNotes = @'
175-
Version 2025.10.26.1521:
175+
Version 2025.10.26.1957:
176176
- Enhanced caching system with OS-wide cache in AppData
177177
- 6-19x performance improvement
178178
- Cache stored in centralized location

ColorScripts-Enhanced/ColorScripts-Enhanced.psm1

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,17 @@ function Save-ColorScriptConfiguration {
238238
$normalizedNew = $json.TrimEnd("`r", "`n")
239239

240240
if (-not $Force) {
241-
$existingContent = $ExistingContent
242-
243-
if (-not $existingContent -and (Test-Path -LiteralPath $script:ConfigurationPath)) {
241+
if (-not $ExistingContent -and (Test-Path -LiteralPath $script:ConfigurationPath)) {
244242
try {
245-
$existingContent = Get-Content -LiteralPath $script:ConfigurationPath -Raw -ErrorAction Stop
243+
$ExistingContent = Get-Content -LiteralPath $script:ConfigurationPath -Raw -ErrorAction Stop
246244
}
247245
catch {
248-
$existingContent = $null
246+
$ExistingContent = $null
249247
}
250248
}
251249

252-
if ($existingContent) {
253-
$normalizedExisting = $existingContent.TrimEnd("`r", "`n")
250+
if ($ExistingContent) {
251+
$normalizedExisting = $ExistingContent.TrimEnd("`r", "`n")
254252
if ($normalizedExisting -eq $normalizedNew) {
255253
return
256254
}
@@ -891,7 +889,7 @@ function Initialize-CacheDirectory {
891889
$script:CacheInitialized = $true
892890
}
893891

894-
Initialize-CacheDirectory
892+
# Cache directory is initialized lazily by public functions when needed
895893

896894
function New-NameMatcherSet {
897895
param(
@@ -1725,7 +1723,7 @@ function Build-ScriptCache {
17251723
The full path to the colorscript file.
17261724
#>
17271725
[CmdletBinding()]
1728-
[OutputType([bool])]
1726+
[OutputType([pscustomobject])]
17291727
param(
17301728
[Parameter(Mandatory)]
17311729
[string]$ScriptPath
@@ -1986,7 +1984,8 @@ function Show-ColorScript {
19861984
$continueLoop = $true
19871985
while ($continueLoop) {
19881986
$key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
1989-
if ($key.VirtualKeyCode -eq 32) { # Spacebar
1987+
if ($key.VirtualKeyCode -eq 32) {
1988+
# Spacebar
19901989
$continueLoop = $false
19911990
}
19921991
elseif ($key.Character -eq 'q' -or $key.Character -eq 'Q') {
@@ -2426,7 +2425,7 @@ function Build-ColorScriptCache {
24262425
$record = $records[$index]
24272426
$scriptName = [string]$record.Name
24282427
$cacheFile = Join-Path $script:CacheDir "$scriptName.cache"
2429-
$percentComplete = if ($totalCount -eq 0) { 0 } else { [int](($index / [double]$totalCount) * 100) }
2428+
$percentComplete = [int](($index / [double]$totalCount) * 100)
24302429
$statusMessage = "Processing {0}/{1}: {2}" -f ($index + 1), $totalCount, $scriptName
24312430
Write-Progress -Id 1 -Activity $progressActivity -Status $statusMessage -PercentComplete $percentComplete -CurrentOperation $scriptName
24322431

ColorScripts-Enhanced/en-US/Add-ColorScriptProfile.md

Lines changed: 75 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
document type: cmdlet
33
external help file: ColorScripts-Enhanced-help.xml
44
HelpUri: https://github.com/Nick2bad4u/ps-color-scripts-enhanced
5+
Locale: en-US
56
Module Name: ColorScripts-Enhanced
67
ms.date: 10/26/2025
78
PlatyPS schema version: 2024-05-01
9+
title: Add-ColorScriptProfile
810
---
911

1012
# Add-ColorScriptProfile
@@ -15,66 +17,67 @@ Appends the ColorScripts-Enhanced module import (and optionally Show-ColorScript
1517

1618
## SYNTAX
1719

18-
### Scope (Default)
19-
20-
```
21-
Add-ColorScriptProfile [-Scope <String>] [-SkipStartupScript] [-Force] [-WhatIf] [-Confirm]
22-
[<CommonParameters>]
23-
```
24-
25-
### Path
26-
27-
```
28-
Add-ColorScriptProfile [-Path <String>] [-SkipStartupScript] [-Force] [-WhatIf] [-Confirm]
29-
[<CommonParameters>]
30-
```
31-
3220
### __AllParameterSets
3321

3422
```
35-
Add-ColorScriptProfile [[-Scope] <string>] [[-Path] <string>] [-SkipStartupScript] [-Force]
23+
Add-ColorScriptProfile [[-Scope] <string>] [[-Path] <string>] [-h] [-SkipStartupScript] [-Force]
3624
[-WhatIf] [-Confirm] [<CommonParameters>]
3725
```
3826

27+
## ALIASES
28+
29+
This cmdlet has the following aliases:
30+
- None
31+
3932
## DESCRIPTION
4033

41-
Adds a startup snippet to the specified PowerShell profile file. The snippet always imports the ColorScripts-Enhanced module and, unless suppressed, adds a call to `Show-ColorScript` so that a random colorscript is displayed on launch. The profile file is created if it does not already exist, and duplicate imports are avoided unless `-Force` is specified.
34+
Adds a startup snippet to the specified PowerShell profile file. The snippet always imports the ColorScripts-Enhanced module and, unless suppressed with `-SkipStartupScript`, adds a call to `Show-ColorScript` so that a random colorscript is displayed on PowerShell launch.
35+
36+
The profile file is created automatically if it does not already exist. Duplicate imports are avoided unless `-Force` is specified.
4237

43-
The `-Path` parameter accepts relative paths, environment variables, and `~` expansion, making it easy to target profiles outside the default locations.
38+
The `-Path` parameter accepts relative paths, environment variables, and `~` expansion, making it easy to target profiles outside the default locations. If `-Path` is not provided, the `-Scope` parameter determines which standard PowerShell profile to modify.
4439

4540
## EXAMPLES
4641

4742
### EXAMPLE 1
4843

44+
Add to the current user's profile for all hosts (default behavior).
45+
4946
```powershell
5047
Add-ColorScriptProfile
5148
```
5249

53-
Updates the CurrentUserAllHosts profile to import the module and show a random colorscript at startup.
50+
This adds both the module import and `Show-ColorScript` call to `$PROFILE.CurrentUserAllHosts`.
5451

5552
### EXAMPLE 2
5653

54+
Add to the current user's profile for the current host only, without the startup script.
55+
5756
```powershell
58-
Add-ColorScriptProfile -SkipStartupScript
57+
Add-ColorScriptProfile -Scope CurrentUserCurrentHost -SkipStartupScript
5958
```
6059

61-
Appends only the `Import-Module ColorScripts-Enhanced` line without calling `Show-ColorScript`.
60+
This adds only the `Import-Module ColorScripts-Enhanced` line to the current host profile.
6261

6362
### EXAMPLE 3
6463

64+
Add to a custom profile path with environment variable expansion.
65+
6566
```powershell
66-
Add-ColorScriptProfile -Scope CurrentUserCurrentHost
67+
Add-ColorScriptProfile -Path "$env:USERPROFILE\Documents\CustomProfile.ps1"
6768
```
6869

69-
Targets the profile for the current host (e.g., Windows Terminal, VS Code) instead of all hosts.
70+
This targets a specific profile file outside the standard PowerShell profile locations.
7071

7172
### EXAMPLE 4
7273

74+
Force re-add the snippet even if it already exists.
75+
7376
```powershell
74-
Add-ColorScriptProfile -Path "~/PowerShell/Profiles/Example.ps1" -Force
77+
Add-ColorScriptProfile -Force
7578
```
7679

77-
Appends the snippet to a custom profile path (resolved from `~`), even if the import line already exists.
80+
This appends the snippet again, even if the profile already contains an import statement for ColorScripts-Enhanced.
7881

7982
## PARAMETERS
8083

@@ -84,7 +87,7 @@ Prompts you for confirmation before running the cmdlet.
8487

8588
```yaml
8689
Type: System.Management.Automation.SwitchParameter
87-
DefaultValue: False
90+
DefaultValue: ''
8891
SupportsWildcards: false
8992
Aliases:
9093
- cf
@@ -102,11 +105,11 @@ HelpMessage: ''
102105
103106
### -Force
104107
105-
Append the snippet even if the profile already contains an `Import-Module ColorScripts-Enhanced` line.
108+
Append the snippet even if the profile already contains an `Import-Module ColorScripts-Enhanced` line. Use this to force duplicate entries or re-add the snippet after manual removal.
106109

107110
```yaml
108111
Type: System.Management.Automation.SwitchParameter
109-
DefaultValue: False
112+
DefaultValue: ''
110113
SupportsWildcards: false
111114
Aliases: []
112115
ParameterSets:
@@ -121,16 +124,35 @@ AcceptedValues: []
121124
HelpMessage: ''
122125
```
123126

127+
### -h
128+
129+
Displays help information for this cmdlet. Equivalent to using `Get-Help Add-ColorScriptProfile`.
130+
131+
```yaml
132+
Type: System.Management.Automation.SwitchParameter
133+
DefaultValue: ''
134+
SupportsWildcards: false
135+
Aliases:
136+
- help
137+
ParameterSets:
138+
- Name: (All)
139+
Position: Named
140+
IsRequired: false
141+
ValueFromPipeline: false
142+
ValueFromPipelineByPropertyName: false
143+
ValueFromRemainingArguments: false
144+
DontShow: false
145+
AcceptedValues: []
146+
HelpMessage: ''
147+
```
148+
124149
### -Path
125150

126-
Explicit profile path to update. Overrides `-Scope` when provided. Supports environment variables, relative paths, and `~` expansion.
127-
Explicit profile path to update.
128-
Overrides `-Scope` when provided.
129-
Supports environment variables, relative paths, and `~` expansion.
151+
Explicit profile path to update. Overrides `-Scope` when provided. Supports environment variables (e.g., `$env:USERPROFILE`), relative paths, and `~` expansion for the home directory.
130152

131153
```yaml
132154
Type: System.String
133-
DefaultValue: None
155+
DefaultValue: ''
134156
SupportsWildcards: false
135157
Aliases: []
136158
ParameterSets:
@@ -147,14 +169,11 @@ HelpMessage: ''
147169

148170
### -Scope
149171

150-
Profile scope to update when `-Path` is not supplied. Accepts PowerShell's standard profile properties (e.g., `CurrentUserAllHosts`, `CurrentUserCurrentHost`). Defaults to `CurrentUserAllHosts`.
151-
Profile scope to update when `-Path` is not supplied.
152-
Accepts PowerShell's standard profile properties (e.g., `CurrentUserAllHosts`, `CurrentUserCurrentHost`).
153-
Defaults to `CurrentUserAllHosts`.
172+
Profile scope to update when `-Path` is not supplied. Accepts PowerShell's standard profile properties: `CurrentUserAllHosts`, `CurrentUserCurrentHost`, `AllUsersAllHosts`, or `AllUsersCurrentHost`. Defaults to `CurrentUserAllHosts`.
154173

155174
```yaml
156175
Type: System.String
157-
DefaultValue: CurrentUserAllHosts
176+
DefaultValue: 'CurrentUserAllHosts'
158177
SupportsWildcards: false
159178
Aliases: []
160179
ParameterSets:
@@ -171,13 +190,11 @@ HelpMessage: ''
171190

172191
### -SkipStartupScript
173192

174-
Skip adding `Show-ColorScript` to the profile. Only the import line is appended.
175-
Skip adding `Show-ColorScript` to the profile.
176-
Only the import line is appended.
193+
Skip adding `Show-ColorScript` to the profile. Only the `Import-Module ColorScripts-Enhanced` line is appended. Use this if you want to manually control when colorscripts are displayed.
177194

178195
```yaml
179196
Type: System.Management.Automation.SwitchParameter
180-
DefaultValue: False
197+
DefaultValue: ''
181198
SupportsWildcards: false
182199
Aliases: []
183200
ParameterSets:
@@ -195,12 +212,10 @@ HelpMessage: ''
195212
### -WhatIf
196213

197214
Shows what would happen if the cmdlet runs. The cmdlet is not run.
198-
Shows what would happen if the cmdlet runs.
199-
The cmdlet is not run.
200215

201216
```yaml
202217
Type: System.Management.Automation.SwitchParameter
203-
DefaultValue: False
218+
DefaultValue: ''
204219
SupportsWildcards: false
205220
Aliases:
206221
- wi
@@ -227,25 +242,31 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
227242

228243
### None
229244

230-
You cannot pipe objects to this cmdlet.
245+
This cmdlet does not accept pipeline input.
231246

232247
## OUTPUTS
233248

234249
### System.Object
235250

236-
Returns an object containing the profile path, whether a change was made, and a status message.
251+
Returns a custom object with the following properties:
252+
- **ProfilePath** (string): The full path to the modified profile file
253+
- **Changed** (bool): Whether the profile was actually modified
254+
- **Message** (string): A status message describing the operation result
237255

238256
## NOTES
239257

240-
Author: Nick
241-
Module: ColorScripts-Enhanced
242-
Requires: PowerShell 5.1 or later
258+
**Author:** Nick
259+
**Module:** ColorScripts-Enhanced
260+
**Requires:** PowerShell 5.1 or later
261+
262+
The profile file is created automatically if it does not exist, including any necessary parent directories. Duplicate imports are detected and suppressed unless `-Force` is used.
243263

244-
The profile file is created automatically if it does not exist. Duplicate imports are suppressed unless `-Force` is used.
264+
If you need elevated permissions to modify an AllUsers profile, ensure you run PowerShell as Administrator.
245265

246266
## RELATED LINKS
247267

248-
- [Show-ColorScript](Show-ColorScript.md)
249-
- [Build-ColorScriptCache](Build-ColorScriptCache.md)
250-
- [Clear-ColorScriptCache](Clear-ColorScriptCache.md)
251-
- [Online Documentation](https://github.com/Nick2bad4u/ps-color-scripts-enhanced)
268+
- [Online Version](https://github.com/Nick2bad4u/ps-color-scripts-enhanced)
269+
- [Show-ColorScript](./Show-ColorScript.md)
270+
- [Build-ColorScriptCache](./Build-ColorScriptCache.md)
271+
- [Clear-ColorScriptCache](./Clear-ColorScriptCache.md)
272+
- [GitHub Repository](https://github.com/Nick2bad4u/ps-color-scripts-enhanced)

0 commit comments

Comments
 (0)