Unix 工具:漂亮的打印代码

发布于 2024-12-09 19:39:43 字数 1061 浏览 0 评论 0原文

我正在将代码移植到不同的语言并在不同的服务器上运行它等。

作为第一步:我们只是打印出运行的命令,因为实际环境有太多环境问题需要解决。因此,目前我们正在生成的输出是:

    fn a
    {
    executing blah 
    executing blah 
    executing blah 
    fn b
    {
    executing blah  
    executing blah 
    fn c
    {
    executing blah 
    executing blah 
    }

    }
    }

这是一个大转储,我们希望在开始移植之前通过“阅读”对其进行审查。我正在寻找一个简单的实用程序,我可以通过它传递或捕获带有代码的文件,并且它会为我们漂亮地打印它。

大多数情况下,只有大括号也可以。但最多可以达到多个级别。所以上面的代码应该看起来像:

   fn a
    {
    executing blah 
    executing blah 
    executing blah 
      fn b
      {
      executing blah  
      executing blah 
        fn c
        {
        executing blah 
        executing blah 
        }

      }
    }

在 unix 中类似的东西有用吗?

astyle --style=allman /路径/文件:

   fn a
   {
      executing blah 
      executing blah 
      executing blah 
      fn b
   {
      executing blah  
      executing blah 
      fn c
      {
          executing blah 
          executing blah 
      }

   }
   }

谢谢!

I am in the process of porting a code to different language and running it on different servers etc.

As a step1 : we are just printing out the commands that are run since there are too many env issues to go through for actual env. So currently the output we are producing is :

    fn a
    {
    executing blah 
    executing blah 
    executing blah 
    fn b
    {
    executing blah  
    executing blah 
    fn c
    {
    executing blah 
    executing blah 
    }

    }
    }

This is a big dump that we want to review by "reading" before we start porting it. I am looking for a simple utility that I can pass or cat a file with code and it will pretty print it for us.

Mostly just the braces is fine as well ..but upto multiple level. So above code should look like:

   fn a
    {
    executing blah 
    executing blah 
    executing blah 
      fn b
      {
      executing blah  
      executing blah 
        fn c
        {
        executing blah 
        executing blah 
        }

      }
    }

Is something like that avail in unix ?

astyle --style=allman /path/file:

   fn a
   {
      executing blah 
      executing blah 
      executing blah 
      fn b
   {
      executing blah  
      executing blah 
      fn c
      {
          executing blah 
          executing blah 
      }

   }
   }

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

智商已欠费 2024-12-16 19:39:43

indent 是您正在寻找的工具。

indent is the tool you are looking for.

太阳男子 2024-12-16 19:39:43

此类事情通常的备用方法是 enscripta2ps

The usual stand-bys for this sort of thing are enscript and a2ps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文