开发者

Unix tool : pretty print code

开发者 https://www.devze.com 2023-04-13 07:54 出处:网络
I am in the process of porting a code to different language and running it on different servers etc.

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 开发者_运维技巧!


indent is the tool you are looking for.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消