Created
August 31, 2020 19:44
-
-
Save brunomartinspro/ffae4e403d61934a1c961d51fb9b2dc3 to your computer and use it in GitHub Desktop.
Groovy Wonderland - Enables locating parallel files in parallel universes!
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
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!") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Run the script in your current location.
Create
Delete
GroovyWonderland.ps1 -delete