Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Groovy Wonderland - Enables locating parallel files in parallel universes!
param ([switch]$delete)
$currentLocation = Get-Location
$counter = 1
if(!$delete) {
Get-ChildItem $currentLocation -Filter "*.groovy" -recurse | Foreach-Object {
Write-Output ("----------------- File Start: " + $_.FullName + "----------------------")
try {
$regex = '(def call\(body\) \{)'
(Get-Content $_.FullName) -replace $regex, "def call(body) { $([Environment]::NewLine) println('CodeName: Wonderland ($counter)')" | Set-Content $_.FullName
$counter += 1
Write-Output (Get-Content $_.FullName)
}
catch {
Write-Output ("Error: $_")
}
Write-Output ("----------------- File End: " + $_.FullName + "----------------------")
}
Write-Output ("Welcome to the Wonderland!")
}
else {
Get-ChildItem $currentLocation -Filter "*.groovy" -recurse | Foreach-Object {
Write-Output ("----------------- File Start: " + $_.FullName + "----------------------")
try {
$regex = "(println\(\'CodeName\: Wonderland \(.*\)\'\))"
(Get-Content $_.FullName) -replace $regex, "" | Set-Content $_.FullName
Write-Output (Get-Content $_.FullName)
}
catch {
Write-Output ("Error: $_")
}
Write-Output ("----------------- File End: " + $_.FullName + "----------------------")
}
Write-Output ("Hope you liked the Wonderland!")
}
@brunomartinspro

This comment has been minimized.

Copy link
Owner Author

@brunomartinspro brunomartinspro commented Aug 31, 2020

Usage

Run the script in your current location.

Create

GroovyWonderland.ps1 

Delete

GroovyWonderland.ps1 -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment