Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell Code Tidy or Reformat? [duplicate]

Tags:

powershell

Possible Duplicate:
Is there a PowerShell code formatter / pretty printer?

Does anyone know of a tool that you can use to re-format/tidy Powershell code:-

Eg:-

if ($c -eq "Cat") 
{
$a="Bubble" 
}
else
{
$a="Trouble"
}
Write-Host $a

To:-

if ($c -eq "Cat") 
{
    $a="Bubble" 
}
else
{
    $a="Trouble"
}
Write-Host $a

ie, tabbing If Statements etc, I know they was tools to do it with VB but I haven't seen any for Powershell yet?


1 Answers

Quick update - it's now on GitHub: https://github.com/DTW-DanWard/PowerShell-Beautifier I wrote a PowerShell pretty printer / code cleaner in PowerShell. It cleans white space, indents code groups, replaces aliases with commands, fixes casing on commands, parameters, types, etc. You can use it to reformat a file in place or read a source file and output the result in a different file.

like image 182
DanW Avatar answered Sep 14 '25 00:09

DanW