C/C++代碼格式優化工具----astyle

Artistic style is a console program that receives information from the command line. The format of the command line is:

astyle  [options]  SourceFile1  SourceFile2  SourceFile3  [ . . . ]

The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT actually included in the command. For the options format see the following Options section.

  Example to format a single file:

astyle  --style=allman  /home/user/project/foo.cpp

  Example to format all .cpp and .h files recursively:

astyle  --style=allman --recursive  /home/user/project/*.cpp  /home/user/project/*.h

Another option will format a single file and change the name:

astyle [options] < OriginalSourceFile > BeautifiedSourceFile

The < and > characters are used to redirect the files into standard input (cin) and out of standard output (cout) - don't forget them! With this option only one file at a time can be formatted. Wildcards are not recognized, there are no console messages, and a backup is not created. On Windows the output will always have Windows line ends.

 

Options

Not specifying any option will result in 4 spaces per indent, no change in bracket placement, and no formatting changes.

Options may be written in two different ways.

Long options

These options start with '--', and must be written one at a time.
(Example: '--brackets=attach --indent=spaces=4')

Short Options

These options start with a single '-', and may be concatenated together.
(Example: '-bps4' is the same as writing '-b -p -s4'.)

Bracket Style Options

default bracket style    style=allman    style=java    style=kr    style=stroustrup   

 style=whitesmith    style=banner   style=gnu    style=linux    style=horstmann    

style=1tbs    style=pico    style=lisp   

Tab Options

default indent    indent=spaces    indent=tab    indent=force‑tab    --indent=force‑tab‑x   

Indentation Options

indent‑classes    indent‑switches    indent‑cases    indent‑namespaces    indent‑labels    

indent‑preprocessor   indent‑col1‑comments    min‑conditional‑indent    max‑instatement‑indent   

Padding Options

break‑blocks    break‑blocks=all    pad‑oper    pad‑paren    pad‑paren‑out    pad‑first‑paren‑out   

 pad‑paren‑in    pad‑header   unpad‑paren    delete‑empty‑lines    fill‑empty‑lines    align‑pointer  

  align‑reference   

Formatting Options

break‑closing‑brackets    break‑elseifs    add‑brackets    add‑one‑line‑brackets    keep‑one‑line‑blocks  

  keep‑one‑line‑statements   convert‑tabs    close‑templates    max‑code‑length    break‑after‑logical   

 mode   

Other Options

suffix    suffix=none    recursive    exclude    ignore‑exclude‑errors    ignore‑exclude‑errors‑x    

errors‑to‑stdout   preserve‑date    verbose    formatted    quiet    lineend   



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章