PowerShell 代码整理还是重新格式化? [英] PowerShell Code Tidy or Reformat?

查看:55
本文介绍了PowerShell 代码整理还是重新格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
是否有 PowerShell 代码格式化程序/漂亮的打印机? >

有谁知道可以用来重新格式化/整理 Powershell 代码的工具:-

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

例如:-

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

致:-

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

即,tabing If Statements 等,我知道它们是用 VB 完成的工具,但我还没有看到任何用于 Powershell 的工具?

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

推荐答案

快速更新 - 现在在 GitHub 上:https://github.com/DTW-DanWard/PowerShell-Beautifier我在 PowerShell 中编写了一个 PowerShell 漂亮的打印机/代码清理器.它清理空白、缩进代码组、用命令替换别名、修复命令、参数、类型等的大小写.您可以使用它来重新格式化文件或读取源文件并将结果输出到不同的文件中.

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.

这篇关于PowerShell 代码整理还是重新格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆