-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fc3930
commit 3c9b2c6
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
function Show-ColorScript { | ||
<# | ||
.SYNOPSIS | ||
Prints a random color script to the console. | ||
.DESCRIPTION | ||
Prints a random color script to the console. Use the -Name parameter to print a specific script. Use the -List parameter to list all available scripts. | ||
.PARAMETER Name | ||
The name of the script to print. | ||
.PARAMETER List | ||
List all available scripts. | ||
.EXAMPLE | ||
Show-ColorScript | ||
Prints a random script. | ||
.EXAMPLE | ||
Show-ColorScript -Name "elfman" | ||
Prints the elfman script. | ||
.EXAMPLE | ||
Show-ColorScript -List | ||
Prints a list of all available scripts. | ||
#> | ||
param( | ||
[Parameter(Mandatory = $false)] | ||
[string]$Name, | ||
[Parameter(Mandatory = $false)] | ||
[switch]$List | ||
) | ||
|
||
if ($List) { | ||
# List all scripts | ||
$scripts = Get-ChildItem -Path "$PSScriptRoot/colorscripts" -Filter *.ps1 | ||
$scripts | ForEach-Object { | ||
Write-Host $_.BaseName | ||
} | ||
|
||
return | ||
} | ||
|
||
if ($Name) { | ||
# Get script by name | ||
$script = Get-ChildItem -Path "$PSScriptRoot/colorscripts" -Filter "$Name.ps1" | ||
if ($script) { | ||
# Run script | ||
& $script.FullName | ||
} else { | ||
Write-Error "Script '$Name' not found" | ||
} | ||
|
||
return | ||
} | ||
|
||
$scripts = Get-ChildItem -Path "$PSScriptRoot/colorscripts" -Filter *.ps1 | ||
|
||
# Get random script | ||
$script = $scripts | Get-Random | ||
|
||
# Run script | ||
& $script.FullName | ||
} |